mirror of
https://github.com/tildeverse/lobsters
synced 2024-06-28 11:07:04 +00:00
parent
ab5973f203
commit
17bdf34667
|
@ -416,7 +416,8 @@ private
|
|||
@story.is_hidden_by_cur_user = @story.is_hidden_by_user?(@user)
|
||||
@story.is_saved_by_cur_user = @story.is_saved_by_user?(@user)
|
||||
|
||||
@votes = Vote.comment_votes_by_user_for_story_hash(@user.id, @story.id)
|
||||
@votes = Vote.comment_votes_by_user_for_story_hash(
|
||||
@user.id, (@story.merged_stories.ids).push(@story.id))
|
||||
@comments.each do |c|
|
||||
if @votes[c.id]
|
||||
c.current_vote = @votes[c.id]
|
||||
|
|
|
@ -4,8 +4,10 @@ require 'rails_helper'
|
|||
# so the call can't just be click_on('delete'), etc.
|
||||
|
||||
RSpec.feature "Commenting" do
|
||||
let(:story) { create(:story) }
|
||||
let(:user) { create(:user) }
|
||||
let(:user1) { create(:user) }
|
||||
let(:story) { create(:story, user: user) }
|
||||
let(:story1) { create(:story, user: user1) }
|
||||
|
||||
before(:each) { stub_login_as user }
|
||||
|
||||
|
@ -71,5 +73,23 @@ RSpec.feature "Commenting" do
|
|||
comment.reload
|
||||
expect(comment.user).to eq(user)
|
||||
end
|
||||
|
||||
feature "Merging story comments" do
|
||||
scenario "upvote merged story comments" do
|
||||
comment = create(:comment, user_id: user.id, story_id: story.id, created_at: 90.days.ago)
|
||||
|
||||
stub_login_as user1
|
||||
visit "/s/#{story.short_id}"
|
||||
expect(page.find(:css, ".comment .comment_text")).to have_content('comment text 5')
|
||||
expect(comment.upvotes).to eq(1)
|
||||
page.driver.post "/comments/#{comment.short_id}/upvote"
|
||||
comment.reload
|
||||
expect(comment.upvotes).to eq(2)
|
||||
|
||||
story1.update(merged_stories: [story])
|
||||
visit "/s/#{story1.short_id}"
|
||||
expect(page.find(:css, ".comment.upvoted .score")).to have_content('2')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
module AuthenticationHelper
|
||||
def stub_login_as user
|
||||
user.update_column(:session_token, 'asdf')
|
||||
allow_any_instance_of(ApplicationController).to receive(:session).and_return(u: 'asdf')
|
||||
random_token = "abcdefg".split('').shuffle.join
|
||||
user.update_column(:session_token, random_token)
|
||||
allow_any_instance_of(ApplicationController).to receive(:session).and_return(u: random_token)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user