From 5a027f3a0a3c9f5f2192af9d1c94274e7de86405 Mon Sep 17 00:00:00 2001 From: decabeza Date: Tue, 18 Dec 2018 12:46:12 +0100 Subject: [PATCH 1/2] Removes create question button on proposals index and show --- app/views/proposals/_proposal.html.erb | 8 -------- app/views/proposals/show.html.erb | 7 ------- 2 files changed, 15 deletions(-) diff --git a/app/views/proposals/_proposal.html.erb b/app/views/proposals/_proposal.html.erb index 8ceca43b6..d33b346db 100644 --- a/app/views/proposals/_proposal.html.erb +++ b/app/views/proposals/_proposal.html.erb @@ -66,18 +66,10 @@ class="small-12 medium-3 column supports-container"> <% if proposal.successful? %>
-

<%= t("proposals.proposal.successful") %>

- <% if can? :create, Poll::Question %> -

- <%= link_to t('poll_questions.create_question'), - new_admin_question_path(proposal_id: proposal.id), - class: "button hollow" %> -

- <% end %> <% elsif proposal.archived? %>
<%= t("proposals.proposal.supports", count: proposal.total_votes) %> diff --git a/app/views/proposals/show.html.erb b/app/views/proposals/show.html.erb index cd9ba74f0..3ac5e03df 100644 --- a/app/views/proposals/show.html.erb +++ b/app/views/proposals/show.html.erb @@ -88,13 +88,6 @@

<%= t("proposals.proposal.successful") %>

- <% if can? :create, Poll::Question %> -

- <%= link_to t('poll_questions.create_question'), - new_admin_question_path(proposal_id: @proposal.id), - class: "button hollow expanded" %> -

- <% end %> <% elsif @proposal.archived? %>

From aebd29f7e2749fca7a4f7ae0158658b541480507 Mon Sep 17 00:00:00 2001 From: decabeza Date: Wed, 19 Dec 2018 16:08:57 +0100 Subject: [PATCH 2/2] Adds create question button to admin proposals show --- app/assets/stylesheets/layout.scss | 5 ++++ app/views/admin/proposals/show.html.erb | 12 +++++++++ spec/features/admin/poll/questions_spec.rb | 16 +++--------- spec/features/admin/proposals_spec.rb | 30 ++++++++++++++++++---- spec/features/proposals_spec.rb | 16 ++++++++---- 5 files changed, 56 insertions(+), 23 deletions(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 7f4e1bb82..14ec9e354 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -1093,6 +1093,7 @@ form { .callout { font-size: $small-font-size; + overflow: hidden; a:not(.button) { font-weight: bold; @@ -1132,6 +1133,10 @@ form { .close { text-decoration: none !important; } + + .button { + margin-bottom: 0; + } } .no-error { diff --git a/app/views/admin/proposals/show.html.erb b/app/views/admin/proposals/show.html.erb index 762c65592..c646b0eed 100644 --- a/app/views/admin/proposals/show.html.erb +++ b/app/views/admin/proposals/show.html.erb @@ -5,6 +5,18 @@

<%= @proposal.title %>

+ <% if @proposal.successful? %> +
+ <%= t("proposals.proposal.successful") %> + +
+ <%= link_to t("poll_questions.create_question"), + new_admin_question_path(proposal_id: @proposal.id), + class: "button medium" %> +
+
+ <% end %> + <%= render "proposals/info", proposal: @proposal %>
diff --git a/spec/features/admin/poll/questions_spec.rb b/spec/features/admin/poll/questions_spec.rb index 5fedcbb34..65aead571 100644 --- a/spec/features/admin/poll/questions_spec.rb +++ b/spec/features/admin/poll/questions_spec.rb @@ -53,11 +53,12 @@ feature 'Admin poll questions' do expect(page).to have_content(title) end - scenario 'Create from successful proposal index' do + scenario 'Create from successful proposal' do poll = create(:poll, name: 'Proposals') proposal = create(:proposal, :successful) - visit proposals_path + visit admin_proposal_path(proposal) + click_link "Create question" expect(page).to have_current_path(new_admin_question_path, ignore_query: true) @@ -72,17 +73,6 @@ feature 'Admin poll questions' do expect(page).to have_link(proposal.author.name, href: user_path(proposal.author)) end - scenario "Create from successful proposal show" do - poll = create(:poll, name: 'Proposals') - proposal = create(:proposal, :successful) - - visit proposal_path(proposal) - click_link "Create question" - - expect(page).to have_current_path(new_admin_question_path, ignore_query: true) - expect(page).to have_field('Question', with: proposal.title) - end - scenario 'Update' do question1 = create(:poll_question) diff --git a/spec/features/admin/proposals_spec.rb b/spec/features/admin/proposals_spec.rb index ddad53d9c..d1d8c5cc0 100644 --- a/spec/features/admin/proposals_spec.rb +++ b/spec/features/admin/proposals_spec.rb @@ -28,12 +28,32 @@ feature "Admin proposals" do end end - scenario "Show" do - create(:proposal, title: "Create a chaotic future", summary: "Chaos isn't controlled") + context "Show" do - visit admin_proposals_path - click_link "Create a chaotic future" + scenario "View proposal" do + create(:proposal, title: "Create a chaotic future", summary: "Chaos isn't controlled") - expect(page).to have_content "Chaos isn't controlled" + visit admin_proposals_path + click_link "Create a chaotic future" + + expect(page).to have_content "Chaos isn't controlled" + expect(page).not_to have_content "This proposal has reached the required supports" + expect(page).not_to have_link "Create question" + end + + scenario "Successful proposals show create question button" do + successful_proposals = create_successful_proposals + admin = create(:administrator) + + login_as(admin.user) + + visit admin_proposals_path + + 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" + end + end end end diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index 9628ea9f8..e36d9c6cd 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -1789,8 +1789,11 @@ feature 'Successful proposals' do end end - scenario 'Successful proposals show create question button to admin users' do + scenario 'Successful proposals do not show create question button in index' do successful_proposals = create_successful_proposals + admin = create(:administrator) + + login_as(admin.user) visit proposals_path @@ -1799,17 +1802,20 @@ feature 'Successful proposals' do expect(page).not_to have_link "Create question" end end + end - login_as(create(:administrator).user) + scenario 'Successful proposals do not show create question button in show' do + successful_proposals = create_successful_proposals + admin = create(:administrator) - visit proposals_path + login_as(admin.user) successful_proposals.each do |proposal| + visit proposal_path(proposal) within("#proposal_#{proposal.id}_votes") do - expect(page).to have_link "Create question" + expect(page).not_to have_link "Create question" end end - end context "Skip user verification" do