Fix obsolete respond_with_bip usage

Since we removed the `best_in_place` gem, this method doesn't exist
anymore. We're replacing it with what the method actually does.

Note the test doesn't check the poll is correctly updated. We could add
a `visit proposal_dashboard_polls_path(proposal)` before checking the
"Show results" field, but then we would enter a race condition between
this request and the AJAX request. A proper solution would be to provide
actual feedback to the user so they know the poll has been updated, and
then checking that feedback is present in the tests.
This commit is contained in:
Javi Martín
2019-05-08 19:45:31 +02:00
parent a1d6885132
commit 55c8fa3297
2 changed files with 15 additions and 2 deletions

View File

@@ -35,10 +35,10 @@ class Dashboard::PollsController < Dashboard::BaseController
if poll.update(poll_params)
format.html { redirect_to proposal_dashboard_polls_path(proposal),
notice: t("flash.actions.update.poll") }
format.json { respond_with_bip(poll) }
format.json { head :no_content }
else
format.html { render :edit }
format.json { respond_with_bip(poll) }
format.json { render json: poll.errors.full_messages, status: :unprocessable_entity }
end
end
end

View File

@@ -197,6 +197,19 @@ feature "Polls" do
end
end
scenario "Enable and disable results", :js do
create(:poll, related: proposal)
visit proposal_dashboard_polls_path(proposal)
check "Show results"
expect(find_field("Show results")).to be_checked
uncheck "Show results"
expect(find_field("Show results")).not_to be_checked
end
scenario "Poll card" do
poll = create(:poll, :expired, related: proposal)