We removed the link to this page in commit 83e8d6035 because poll
questions don't really make sense without a poll.
However, this page also contained information about successful
proposals, which might be interesting so administrators don't have to
navigate to the public area in order to find and create questions based
on successful proposals.
So we're keeping the part about successful proposals and linking it from
the proposals part of the admin area.
Note we're using translation keys like `successful_proposals_tab`, which
don't make sense anymore, for the successful proposals. We're doing so
because we've already got translations for these keys and, if we renamed
them, we'd lose the existing translations and our translators would have
to add them again.
Also note we're changing one poll question test a little bit so we
create the question from a successful proposal using the new page. There
are other tests checking how to create a question from the
admin/proposals#show action and other tests checking what happens when
accessing a successful proposal in the admin section, so we don't lose
any test coverage by changing an existing test instead of adding a new
one.
Finally, note that we've removing the `search` method in poll question
because we no longer use it. This currently makes the
`author_visible_name` database column useless; we aren't removing it
right now because we don't want to risk a possible data loss in a patch
release (we're about to release version 2.3.1), but we might remove it
in the future.
36 lines
1.1 KiB
Ruby
36 lines
1.1 KiB
Ruby
require "rails_helper"
|
|
|
|
describe Admin::Proposals::IndexComponent, controller: Admin::ProposalsController do
|
|
around do |example|
|
|
with_request_url(Rails.application.routes.url_helpers.admin_proposals_path) { example.run }
|
|
end
|
|
|
|
describe "#successful_proposals_link" do
|
|
it "is shown when there are successful proposals" do
|
|
create(:proposal, :successful)
|
|
|
|
render_inline Admin::Proposals::IndexComponent.new(Proposal.page(1))
|
|
|
|
expect(page).to have_link "Successful proposals"
|
|
end
|
|
|
|
it "is not shown when there aren't any successful proposals" do
|
|
create(:proposal)
|
|
|
|
render_inline Admin::Proposals::IndexComponent.new(Proposal.page(1))
|
|
|
|
expect(page).not_to have_link "Successful proposals"
|
|
end
|
|
|
|
it "is shown when there are successful proposals on a previous page" do
|
|
allow(Proposal).to receive(:default_per_page).and_return(1)
|
|
create(:proposal, :successful)
|
|
create(:proposal)
|
|
|
|
render_inline Admin::Proposals::IndexComponent.new(Proposal.order(:id).page(2))
|
|
|
|
expect(page).to have_link "Successful proposals"
|
|
end
|
|
end
|
|
end
|