Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly update flag/unflag icon when clicked over debates#show #1526

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/views/debates/_refresh_flag_actions.js.erb
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
$("#<%= dom_id(@debate) %> .js-flag-actions").html("<%= j render("debates/flag_actions", debate: @debate) %>");
App.Flaggable.update("<%= dom_id(@debate) %>",
"<%= j render("debates/flag_actions", debate: @debate) %>")
28 changes: 27 additions & 1 deletion spec/features/debates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,33 @@
expect(Flag.flagged?(user, debate)).not_to be
end

describe "Debate index order filters" do
scenario 'Flagging a debate updates the DOM properly', :js do
user = create(:user)
debate = create(:debate)

login_as(user)
visit debate_path(debate)

within "#debate_#{debate.id}" do
find("#flag-expand-debate-#{debate.id}").click
find("#flag-debate-#{debate.id}").click

expect(page).to have_css("#unflag-expand-debate-#{debate.id}")
end

expect(Flag.flagged?(user, debate)).to be

within "#debate_#{debate.id}" do
find("#unflag-expand-debate-#{debate.id}").click
find("#unflag-debate-#{debate.id}").click

expect(page).to have_css("#flag-expand-debate-#{debate.id}")
end

expect(Flag.flagged?(user, debate)).not_to be
end

feature 'Debate index order filters' do

scenario "Default order is hot_score", :js do
best_debate = create(:debate, title: "Best")
Expand Down