From 74958fab02a355fb85786da017a763dfc8ad9793 Mon Sep 17 00:00:00 2001 From: decabeza Date: Wed, 13 Mar 2019 13:28:12 +0100 Subject: [PATCH] Always show create question button on admin proposal show --- app/views/admin/proposals/show.html.erb | 10 ++++++-- config/locales/en/admin.yml | 2 ++ config/locales/en/general.yml | 1 - config/locales/es/admin.yml | 2 ++ config/locales/es/general.yml | 1 - spec/features/admin/poll/questions_spec.rb | 30 +++++++++++++++++----- spec/features/admin/proposals_spec.rb | 2 +- 7 files changed, 37 insertions(+), 11 deletions(-) diff --git a/app/views/admin/proposals/show.html.erb b/app/views/admin/proposals/show.html.erb index c646b0eed..13fbce01e 100644 --- a/app/views/admin/proposals/show.html.erb +++ b/app/views/admin/proposals/show.html.erb @@ -3,18 +3,24 @@ <% end %>
-

<%= @proposal.title %>

+

<%= @proposal.title %>

<% if @proposal.successful? %>
<%= t("proposals.proposal.successful") %>
- <%= link_to t("poll_questions.create_question"), + <%= link_to t("admin.proposals.show.create_question"), new_admin_question_path(proposal_id: @proposal.id), class: "button medium" %>
+ <% else %> +
+ <%= link_to t("admin.proposals.show.create_question"), + new_admin_question_path(proposal_id: @proposal.id), + class: "button hollow medium" %> +
<% end %> <%= render "proposals/info", proposal: @proposal %> diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 14ac97c05..6437a1720 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -1144,6 +1144,8 @@ en: author: Author milestones: Milestones no_proposals: There are no proposals. + show: + create_question: Add this proposal to a poll to be voted hidden_proposals: index: filter: Filter diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index e2ce16257..562d6b072 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -508,7 +508,6 @@ en: title: "Questions" most_voted_answer: "Most voted answer: " poll_questions: - create_question: "Create question" show: vote_answer: "Vote %{answer}" voted: "You have voted %{answer}" diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 946adc6b4..5cb8ee9bd 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -1143,6 +1143,8 @@ es: author: Autor milestones: Hitos no_proposals: No hay propuestas. + show: + create_question: Añadir esta propuesta a una votación para ser votada hidden_proposals: index: filter: Filtro diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 02ff6120e..4751cd027 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -508,7 +508,6 @@ es: title: "Preguntas" most_voted_answer: "Respuesta más votada: " poll_questions: - create_question: "Crear pregunta" show: vote_answer: "Votar %{answer}" voted: "Has votado %{answer}" diff --git a/spec/features/admin/poll/questions_spec.rb b/spec/features/admin/poll/questions_spec.rb index 29083b99b..2306caf14 100644 --- a/spec/features/admin/poll/questions_spec.rb +++ b/spec/features/admin/poll/questions_spec.rb @@ -62,13 +62,33 @@ feature "Admin poll questions" do expect(page).to have_content(title) end - scenario "Create from successful proposal" do - poll = create(:poll, name: "Proposals") - proposal = create(:proposal, :successful) + scenario "Create from proposal" do + create(:poll, name: "Proposals") + proposal = create(:proposal) visit admin_proposal_path(proposal) - click_link "Create question" + expect(page).not_to have_content("This proposal has reached the required supports") + click_link "Add this proposal to a poll to be voted" + + expect(page).to have_current_path(new_admin_question_path, ignore_query: true) + expect(page).to have_field("Question", with: proposal.title) + + select "Proposals", from: "poll_question_poll_id" + + click_button "Save" + + expect(page).to have_content(proposal.title) + end + + scenario "Create from successful proposal" do + create(:poll, name: "Proposals") + proposal = create(:proposal, :successful) + + visit admin_proposal_path(proposal) + + expect(page).to have_content("This proposal has reached the required supports") + click_link "Add this proposal to a poll to be voted" expect(page).to have_current_path(new_admin_question_path, ignore_query: true) expect(page).to have_field("Question", with: proposal.title) @@ -78,8 +98,6 @@ feature "Admin poll questions" do click_button "Save" expect(page).to have_content(proposal.title) - expect(page).to have_link(proposal.title, href: proposal_path(proposal)) - expect(page).to have_link(proposal.author.name, href: user_path(proposal.author)) end scenario "Update" do diff --git a/spec/features/admin/proposals_spec.rb b/spec/features/admin/proposals_spec.rb index d1d8c5cc0..affc723f7 100644 --- a/spec/features/admin/proposals_spec.rb +++ b/spec/features/admin/proposals_spec.rb @@ -52,7 +52,7 @@ feature "Admin proposals" do successful_proposals.each do |proposal| visit admin_proposal_path(proposal) expect(page).to have_content "This proposal has reached the required supports" - expect(page).to have_link "Create question" + expect(page).to have_link "Add this proposal to a poll to be voted" end end end