From b2c79174aa1b93ff1a4bac167024ab7a1afe582c Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 30 May 2017 15:39:47 +0200 Subject: [PATCH 01/10] Add new Proposal share endpoint, plus ability for ereryone to use it --- app/controllers/proposals_controller.rb | 3 +++ app/models/abilities/everyone.rb | 2 +- config/routes.rb | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index d1707a8a7..0cfa2c6dd 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -45,6 +45,9 @@ class ProposalsController < ApplicationController def retire_form end + def share + end + def vote_featured @proposal.register_vote(current_user, 'yes') set_featured_proposal_votes(@proposal) diff --git a/app/models/abilities/everyone.rb b/app/models/abilities/everyone.rb index c2b6cd6d7..2b2b913cc 100644 --- a/app/models/abilities/everyone.rb +++ b/app/models/abilities/everyone.rb @@ -4,7 +4,7 @@ module Abilities def initialize(user) can [:read, :map], Debate - can [:read, :map, :summary], Proposal + can [:read, :map, :summary, :share], Proposal can :read, Comment can :read, Poll can :read, Poll::Question diff --git a/config/routes.rb b/config/routes.rb index ebd275353..b43f41ad5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -52,6 +52,7 @@ Rails.application.routes.draw do put :flag put :unflag get :retire_form + get :share patch :retire end collection do From 29f59e2af53487bf9ef71eab9b5947f6908808a5 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 30 May 2017 15:40:53 +0200 Subject: [PATCH 02/10] Add create method on proposals controller to redirect to proposal share page with notice after save --- app/controllers/proposals_controller.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 0cfa2c6dd..6d17908ad 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -3,7 +3,7 @@ class ProposalsController < ApplicationController include FlagActions before_action :parse_tag_filter, only: :index - before_action :load_categories, only: [:index, :new, :edit, :map, :summary] + before_action :load_categories, only: [:index, :new, :create, :edit, :map, :summary] before_action :load_geozones, only: [:edit, :map, :summary] before_action :authenticate_user!, except: [:index, :show, :map, :summary] @@ -22,6 +22,17 @@ class ProposalsController < ApplicationController redirect_to proposal_path(@proposal), status: :moved_permanently if request.path != proposal_path(@proposal) end + def create + @proposal = Proposal.new(proposal_params) + @proposal.author = current_user + + if @proposal.save + redirect_to share_proposal_path(@proposal), notice: I18n.t("flash.actions.create.proposal") + else + render :new + end + end + def index_customization discard_archived load_retired From fbea920b5c7afef90d3c661affbabbe4362c80cb Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 30 May 2017 15:41:34 +0200 Subject: [PATCH 03/10] Add new Proposal Share view plus update social share partial to allow no share_title and divider --- app/views/proposals/share.html.erb | 42 +++++++++++++++++++++++++ app/views/shared/_social_share.html.erb | 2 ++ 2 files changed, 44 insertions(+) create mode 100644 app/views/proposals/share.html.erb diff --git a/app/views/proposals/share.html.erb b/app/views/proposals/share.html.erb new file mode 100644 index 000000000..c6c9be207 --- /dev/null +++ b/app/views/proposals/share.html.erb @@ -0,0 +1,42 @@ +<% provide :title do %><%= @proposal.title %><% end %> +<% provide :social_media_meta_tags do %> +<%= render "shared/social_media_meta_tags", + social_url: proposal_url(@proposal), + social_title: @proposal.title, + social_description: @proposal.summary %> +<% end %> +<% content_for :canonical do %> + <%= render "shared/canonical", href: proposal_url(@proposal) %> +<% end %> + +<% cache [locale_and_user_status(@proposal), @proposal, @proposal.author, Flag.flagged?(current_user, @proposal), @proposal_votes] do %> +
+
+
+ +

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

+ +

<%= @proposal.title %>

+

+ <%= t("proposals.show.code") %> + <%= @proposal.code %> +

+ + +

<%= t("proposals.proposal.share.guide").html_safe %>

+ + <%= render partial: 'shared/social_share', locals: { + title: @proposal.title, + url: proposal_url(@proposal) + } %> + + + + <%= link_to proposal_path(@proposal), class: 'proposal button hollow float-right' do %> + <%= t("proposals.proposal.share.view_proposal") %> + <% end %> + +
+
+
+<% end %> diff --git a/app/views/shared/_social_share.html.erb b/app/views/shared/_social_share.html.erb index c911d8e76..e32fa2db5 100644 --- a/app/views/shared/_social_share.html.erb +++ b/app/views/shared/_social_share.html.erb @@ -1,5 +1,7 @@ +<% if local_assigns[:share_title].present? %>

<%= share_title %>

+<% end %> From af48ece30c73f16e959fa75971d67dc10f744dd5 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 30 May 2017 22:44:44 +0200 Subject: [PATCH 05/10] Add proposal_improvement_url Setting variable to both seed file and correspondent translation --- config/locales/settings.en.yml | 1 + config/locales/settings.es.yml | 1 + db/dev_seeds.rb | 1 + db/seeds.rb | 3 +++ 4 files changed, 6 insertions(+) diff --git a/config/locales/settings.en.yml b/config/locales/settings.en.yml index d76c64bf3..b7b7dbf71 100755 --- a/config/locales/settings.en.yml +++ b/config/locales/settings.en.yml @@ -44,3 +44,4 @@ en: meta_keywords: "Keywords (SEO)" verification_offices_url: Verification offices URL min_age_to_participate: Minimum age needed to participate + proposal_improvement_url: Proposal improvement info internal link diff --git a/config/locales/settings.es.yml b/config/locales/settings.es.yml index 94493651e..4fdce8766 100644 --- a/config/locales/settings.es.yml +++ b/config/locales/settings.es.yml @@ -44,3 +44,4 @@ es: meta_keywords: "Palabras clave (SEO)" verification_offices_url: URL oficinas verificación min_age_to_participate: Edad mínima para participar + proposal_improvement_url: Link a información para mejorar propuestas diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb index baf137c2d..945059c8f 100644 --- a/db/dev_seeds.rb +++ b/db/dev_seeds.rb @@ -44,6 +44,7 @@ Setting.create(key: 'meta_description', value: 'Citizen Participation and Open G Setting.create(key: 'meta_keywords', value: 'citizen participation, open government') Setting.create(key: 'verification_offices_url', value: 'http://oficinas-atencion-ciudadano.url/') Setting.create(key: 'min_age_to_participate', value: '16') +Setting.create(key: 'proposal_improvement_url', value: nil) puts " ✅" print "Creating Geozones" diff --git a/db/seeds.rb b/db/seeds.rb index eb6bffcd8..4bcce8eca 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -103,3 +103,6 @@ Setting['mailer_from_address'] = 'noreply@consul.dev' # Verification settings Setting['verification_offices_url'] = 'http://oficinas-atencion-ciudadano.url/' Setting['min_age_to_participate'] = 16 + +# Proposal improvement url path ('more-information/proposal-improvement') +Setting['proposal_improvement_url'] = nil From 1d38162bf54a17c0a4f095172def21f91f08e78e Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 30 May 2017 22:45:13 +0200 Subject: [PATCH 06/10] Add translations for new Proposal share view elements --- config/locales/en.yml | 6 ++++++ config/locales/es.yml | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 56b8c6a98..9e9c1ad36 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -351,6 +351,12 @@ en: notice: retired: Proposal retired proposal: + created: "You've created a new proposal!" + share: + guide: "Now you can share it through Twitter, Facebook, Google+, Telegram or Whatsapp (if you're using a mobile device) so people can start supporting.

Before it gets shared you'll be able to change the text as you like." + view_proposal: Not now, go to my proposal + improve_info: "You can also %{improve_info_link} about improving your campaign" + improve_info_link: see more information already_supported: You have already supported this proposal. Share it! comments: one: 1 comment diff --git a/config/locales/es.yml b/config/locales/es.yml index e0f2ba001..efc2da5fe 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -351,6 +351,12 @@ es: notice: retired: Propuesta retirada proposal: + created: "¡Has creado una nueva propuesta!" + share: + guide: "Ahora puedes compartirla en Twitter, Facebook, Google+, Telegram o Whatsapp (si utilizas un dispositivo móvil) para que la gente empieze a apoyarla.

Antes de que se publique el texto en las redes sociales podrás modificarlo a tu gusto" + view_proposal: "Ahora no, ver mi propuesta" + improve_info: "También puedes %{improve_info_link} de como mejorar tu campaña" + improve_info_link: ver más información already_supported: "¡Ya has apoyado esta propuesta, compártela!" comments: one: 1 Comentario From 2a6b82288d5563c7672e6113ed3b2223f4c459b5 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 30 May 2017 23:17:27 +0200 Subject: [PATCH 07/10] Complete Proposal scenario for non-verified user with responsible_name expectaction --- spec/features/proposals_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index 843b74bf5..e25804710 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -230,6 +230,8 @@ feature 'Proposals' do click_button 'Create proposal' expect(page).to have_content 'Proposal created successfully.' + + expect(Proposal.last.responsible_name).to eq(author.document_number) end scenario 'Errors on create' do From 2e29eae471e5264392fd121b3c2f843ba3b27ae5 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 30 May 2017 23:18:18 +0200 Subject: [PATCH 08/10] Add click_link step to pass through Share Proposal view after proposal creation on specs --- spec/features/proposals_spec.rb | 49 ++++++++++++++++++++-------- spec/features/tags/proposals_spec.rb | 18 +++++++--- 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index e25804710..3ddf70443 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -135,9 +135,12 @@ feature 'Proposals' do fill_in 'proposal_tag_list', with: 'Refugees, Solidarity' check 'proposal_terms_of_service' - click_button 'Create proposal' + click_button I18n.t('proposals.new.form.submit_button') expect(page).to have_content 'Proposal created successfully.' + + click_link I18n.t('proposals.proposal.share.view_proposal') + expect(page).to have_content 'Help refugees' expect(page).to have_content '¿Would you like to give assistance to war refugees?' expect(page).to have_content 'In summary, what we want is...' @@ -164,7 +167,7 @@ feature 'Proposals' do fill_in 'proposal_responsible_name', with: 'Some other robot' check 'proposal_terms_of_service' - click_button 'Create proposal' + click_button I18n.t('proposals.new.form.submit_button') expect(page.status_code).to eq(200) expect(page.html).to be_empty @@ -186,7 +189,7 @@ feature 'Proposals' do fill_in 'proposal_responsible_name', with: 'Some other robot' check 'proposal_terms_of_service' - click_button 'Create proposal' + click_button I18n.t('proposals.new.form.submit_button') expect(page).to have_content 'Sorry, that was too quick! Please resubmit' @@ -207,9 +210,12 @@ feature 'Proposals' do fill_in 'proposal_responsible_name', with: 'Isabel Garcia' check 'proposal_terms_of_service' - click_button 'Create proposal' + click_button I18n.t('proposals.new.form.submit_button') expect(page).to have_content 'Proposal created successfully.' + + click_link I18n.t('proposals.proposal.share.view_proposal') + expect(Proposal.last.responsible_name).to eq('Isabel Garcia') end @@ -227,10 +233,11 @@ feature 'Proposals' do fill_in 'proposal_external_url', with: 'http://rescue.org/refugees' check 'proposal_terms_of_service' - click_button 'Create proposal' - + click_button I18n.t('proposals.new.form.submit_button') expect(page).to have_content 'Proposal created successfully.' + click_link I18n.t('proposals.proposal.share.view_proposal') + expect(Proposal.last.responsible_name).to eq(author.document_number) end @@ -239,7 +246,8 @@ feature 'Proposals' do login_as(author) visit new_proposal_path - click_button 'Create proposal' + click_button I18n.t('proposals.new.form.submit_button') + expect(page).to have_content error_message end @@ -256,9 +264,12 @@ feature 'Proposals' do fill_in 'proposal_responsible_name', with: 'Isabel Garcia' check 'proposal_terms_of_service' - click_button 'Create proposal' + click_button I18n.t('proposals.new.form.submit_button') expect(page).to have_content 'Proposal created successfully.' + + click_link I18n.t('proposals.proposal.share.view_proposal') + expect(page).to have_content 'Testing an attack' expect(page.html).to include '

This is alert("an attack");

' expect(page.html).to_not include '' @@ -277,9 +288,12 @@ feature 'Proposals' do fill_in 'proposal_responsible_name', with: 'Isabel Garcia' check 'proposal_terms_of_service' - click_button 'Create proposal' + click_button I18n.t('proposals.new.form.submit_button') expect(page).to have_content 'Proposal created successfully.' + + click_link I18n.t('proposals.proposal.share.view_proposal') + expect(page).to have_content 'Testing auto link' expect(page).to have_link('www.example.org', href: 'http://www.example.org') end @@ -296,9 +310,12 @@ feature 'Proposals' do fill_in 'proposal_responsible_name', with: 'Isabel Garcia' check 'proposal_terms_of_service' - click_button 'Create proposal' + click_button I18n.t('proposals.new.form.submit_button') expect(page).to have_content 'Proposal created successfully.' + + click_link I18n.t('proposals.proposal.share.view_proposal') + expect(page).to have_content 'Testing auto link' expect(page).to have_link('http://example.org', href: 'http://example.org') expect(page).not_to have_link('click me') @@ -328,9 +345,12 @@ feature 'Proposals' do fill_in 'proposal_responsible_name', with: 'Isabel Garcia' check 'proposal_terms_of_service' - click_button 'Create proposal' + click_button I18n.t('proposals.new.form.submit_button') expect(page).to have_content 'Proposal created successfully.' + + click_link I18n.t('proposals.proposal.share.view_proposal') + within "#geozone" do expect(page).to have_content 'All city' end @@ -354,9 +374,12 @@ feature 'Proposals' do check 'proposal_terms_of_service' select('California', from: 'proposal_geozone_id') - click_button 'Create proposal' + click_button I18n.t('proposals.new.form.submit_button') expect(page).to have_content 'Proposal created successfully.' + + click_link I18n.t('proposals.proposal.share.view_proposal') + within "#geozone" do expect(page).to have_content 'California' end @@ -1439,4 +1462,4 @@ feature 'Successful proposals' do end end -end \ No newline at end of file +end diff --git a/spec/features/tags/proposals_spec.rb b/spec/features/tags/proposals_spec.rb index 9d956fae9..bf93c940d 100644 --- a/spec/features/tags/proposals_spec.rb +++ b/spec/features/tags/proposals_spec.rb @@ -77,9 +77,12 @@ feature 'Tags' do fill_in 'proposal_tag_list', with: 'Economía, Hacienda' check 'proposal_terms_of_service' - click_button 'Create proposal' + click_button I18n.t('proposals.new.form.submit_button') expect(page).to have_content 'Proposal created successfully.' + + click_link I18n.t('proposals.proposal.share.view_proposal') + expect(page).to have_content 'Economía' expect(page).to have_content 'Hacienda' end @@ -103,10 +106,12 @@ feature 'Tags' do check 'proposal_terms_of_service' find('.js-add-tag-link', text: 'Education').click - click_button 'Create proposal' + click_button I18n.t('proposals.new.form.submit_button') expect(page).to have_content 'Proposal created successfully.' + click_link I18n.t('proposals.proposal.share.view_proposal') + within "#tags_proposal_#{Proposal.last.id}" do expect(page).to have_content 'Education' expect(page).to_not have_content 'Health' @@ -124,7 +129,7 @@ feature 'Tags' do fill_in 'proposal_tag_list', with: "Impuestos, Economía, Hacienda, Sanidad, Educación, Política, Igualdad" - click_button 'Create proposal' + click_button I18n.t('proposals.new.form.submit_button') expect(page).to have_content error_message expect(page).to have_content 'tags must be less than or equal to 6' @@ -146,9 +151,12 @@ feature 'Tags' do fill_in 'proposal_tag_list', with: 'user_id=1, &a=3, ' - click_button 'Create proposal' + click_button I18n.t('proposals.new.form.submit_button') expect(page).to have_content 'Proposal created successfully.' + + click_link I18n.t('proposals.proposal.share.view_proposal') + expect(page).to have_content 'user_id1' expect(page).to have_content 'a3' expect(page).to have_content 'scriptalert("hey");script' @@ -291,4 +299,4 @@ feature 'Tags' do expect(page).to_not have_content proposal3.title end end -end \ No newline at end of file +end From a0bd158264555007468b0db2beb7b806cfb9ea76 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 30 May 2017 23:31:48 +0200 Subject: [PATCH 09/10] Add new expectations to Proposal Creation to check Share view, and scenario for proposal improvement info link presence --- spec/features/proposals_spec.rb | 69 ++++++++++++++++++++-------- spec/features/tags/proposals_spec.rb | 14 +++--- 2 files changed, 57 insertions(+), 26 deletions(-) diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index 3ddf70443..fd10208a3 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -90,6 +90,7 @@ feature 'Proposals' do end context "Embedded video" do + scenario "Show YouTube video" do proposal = create(:proposal, video_url: "http://www.youtube.com/watch?v=a7UFm6ErMPU") visit proposal_path(proposal) @@ -135,11 +136,13 @@ feature 'Proposals' do fill_in 'proposal_tag_list', with: 'Refugees, Solidarity' check 'proposal_terms_of_service' - click_button I18n.t('proposals.new.form.submit_button') + click_button 'Create proposal' expect(page).to have_content 'Proposal created successfully.' + expect(page).to have_content 'Help refugees' + expect(page).not_to have_content 'You can also see more information about improving your campaign' - click_link I18n.t('proposals.proposal.share.view_proposal') + click_link 'Not now, go to my proposal' expect(page).to have_content 'Help refugees' expect(page).to have_content '¿Would you like to give assistance to war refugees?' @@ -153,6 +156,34 @@ feature 'Proposals' do expect(page).to have_content I18n.l(Proposal.last.created_at.to_date) end + scenario 'Create with proposal improvement info link' do + Setting['proposal_improvement_url'] = 'more-information/proposal-improvement' + author = create(:user) + login_as(author) + + visit new_proposal_path + fill_in 'proposal_title', with: 'Help refugees' + fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?' + fill_in 'proposal_summary', with: 'In summary, what we want is...' + fill_in 'proposal_description', with: 'This is very important because...' + fill_in 'proposal_external_url', with: 'http://rescue.org/refugees' + fill_in 'proposal_video_url', with: 'http://youtube.com' + fill_in 'proposal_responsible_name', with: 'Isabel Garcia' + fill_in 'proposal_tag_list', with: 'Refugees, Solidarity' + check 'proposal_terms_of_service' + + click_button 'Create proposal' + + expect(page).to have_content 'Proposal created successfully.' + expect(page).to have_content 'You can also see more information about improving your campaign' + + click_link 'Not now, go to my proposal' + + expect(page).to have_content 'Help refugees' + + Setting['proposal_improvement_url'] = nil + end + scenario 'Create with invisible_captcha honeypot field' do author = create(:user) login_as(author) @@ -167,7 +198,7 @@ feature 'Proposals' do fill_in 'proposal_responsible_name', with: 'Some other robot' check 'proposal_terms_of_service' - click_button I18n.t('proposals.new.form.submit_button') + click_button 'Create proposal' expect(page.status_code).to eq(200) expect(page.html).to be_empty @@ -189,7 +220,7 @@ feature 'Proposals' do fill_in 'proposal_responsible_name', with: 'Some other robot' check 'proposal_terms_of_service' - click_button I18n.t('proposals.new.form.submit_button') + click_button 'Create proposal' expect(page).to have_content 'Sorry, that was too quick! Please resubmit' @@ -210,11 +241,11 @@ feature 'Proposals' do fill_in 'proposal_responsible_name', with: 'Isabel Garcia' check 'proposal_terms_of_service' - click_button I18n.t('proposals.new.form.submit_button') + click_button 'Create proposal' expect(page).to have_content 'Proposal created successfully.' - click_link I18n.t('proposals.proposal.share.view_proposal') + click_link 'Not now, go to my proposal' expect(Proposal.last.responsible_name).to eq('Isabel Garcia') end @@ -233,10 +264,10 @@ feature 'Proposals' do fill_in 'proposal_external_url', with: 'http://rescue.org/refugees' check 'proposal_terms_of_service' - click_button I18n.t('proposals.new.form.submit_button') + click_button 'Create proposal' expect(page).to have_content 'Proposal created successfully.' - click_link I18n.t('proposals.proposal.share.view_proposal') + click_link 'Not now, go to my proposal' expect(Proposal.last.responsible_name).to eq(author.document_number) end @@ -246,7 +277,7 @@ feature 'Proposals' do login_as(author) visit new_proposal_path - click_button I18n.t('proposals.new.form.submit_button') + click_button 'Create proposal' expect(page).to have_content error_message end @@ -264,11 +295,11 @@ feature 'Proposals' do fill_in 'proposal_responsible_name', with: 'Isabel Garcia' check 'proposal_terms_of_service' - click_button I18n.t('proposals.new.form.submit_button') + click_button 'Create proposal' expect(page).to have_content 'Proposal created successfully.' - click_link I18n.t('proposals.proposal.share.view_proposal') + click_link 'Not now, go to my proposal' expect(page).to have_content 'Testing an attack' expect(page.html).to include '

This is alert("an attack");

' @@ -288,11 +319,11 @@ feature 'Proposals' do fill_in 'proposal_responsible_name', with: 'Isabel Garcia' check 'proposal_terms_of_service' - click_button I18n.t('proposals.new.form.submit_button') + click_button 'Create proposal' expect(page).to have_content 'Proposal created successfully.' - click_link I18n.t('proposals.proposal.share.view_proposal') + click_link 'Not now, go to my proposal' expect(page).to have_content 'Testing auto link' expect(page).to have_link('www.example.org', href: 'http://www.example.org') @@ -310,11 +341,11 @@ feature 'Proposals' do fill_in 'proposal_responsible_name', with: 'Isabel Garcia' check 'proposal_terms_of_service' - click_button I18n.t('proposals.new.form.submit_button') + click_button 'Create proposal' expect(page).to have_content 'Proposal created successfully.' - click_link I18n.t('proposals.proposal.share.view_proposal') + click_link 'Not now, go to my proposal' expect(page).to have_content 'Testing auto link' expect(page).to have_link('http://example.org', href: 'http://example.org') @@ -345,11 +376,11 @@ feature 'Proposals' do fill_in 'proposal_responsible_name', with: 'Isabel Garcia' check 'proposal_terms_of_service' - click_button I18n.t('proposals.new.form.submit_button') + click_button 'Create proposal' expect(page).to have_content 'Proposal created successfully.' - click_link I18n.t('proposals.proposal.share.view_proposal') + click_link 'Not now, go to my proposal' within "#geozone" do expect(page).to have_content 'All city' @@ -374,11 +405,11 @@ feature 'Proposals' do check 'proposal_terms_of_service' select('California', from: 'proposal_geozone_id') - click_button I18n.t('proposals.new.form.submit_button') + click_button 'Create proposal' expect(page).to have_content 'Proposal created successfully.' - click_link I18n.t('proposals.proposal.share.view_proposal') + click_link 'Not now, go to my proposal' within "#geozone" do expect(page).to have_content 'California' diff --git a/spec/features/tags/proposals_spec.rb b/spec/features/tags/proposals_spec.rb index bf93c940d..dbab6a95f 100644 --- a/spec/features/tags/proposals_spec.rb +++ b/spec/features/tags/proposals_spec.rb @@ -77,11 +77,11 @@ feature 'Tags' do fill_in 'proposal_tag_list', with: 'Economía, Hacienda' check 'proposal_terms_of_service' - click_button I18n.t('proposals.new.form.submit_button') + click_button 'Create proposal' expect(page).to have_content 'Proposal created successfully.' - click_link I18n.t('proposals.proposal.share.view_proposal') + click_link 'Not now, go to my proposal' expect(page).to have_content 'Economía' expect(page).to have_content 'Hacienda' @@ -106,11 +106,11 @@ feature 'Tags' do check 'proposal_terms_of_service' find('.js-add-tag-link', text: 'Education').click - click_button I18n.t('proposals.new.form.submit_button') + click_button 'Create proposal' expect(page).to have_content 'Proposal created successfully.' - click_link I18n.t('proposals.proposal.share.view_proposal') + click_link 'Not now, go to my proposal' within "#tags_proposal_#{Proposal.last.id}" do expect(page).to have_content 'Education' @@ -129,7 +129,7 @@ feature 'Tags' do fill_in 'proposal_tag_list', with: "Impuestos, Economía, Hacienda, Sanidad, Educación, Política, Igualdad" - click_button I18n.t('proposals.new.form.submit_button') + click_button 'Create proposal' expect(page).to have_content error_message expect(page).to have_content 'tags must be less than or equal to 6' @@ -151,11 +151,11 @@ feature 'Tags' do fill_in 'proposal_tag_list', with: 'user_id=1, &a=3, ' - click_button I18n.t('proposals.new.form.submit_button') + click_button 'Create proposal' expect(page).to have_content 'Proposal created successfully.' - click_link I18n.t('proposals.proposal.share.view_proposal') + click_link 'Not now, go to my proposal' expect(page).to have_content 'user_id1' expect(page).to have_content 'a3' From 438aaa65f67e5d9daf9007ee25496a1dee30c3db Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 31 May 2017 01:05:16 +0200 Subject: [PATCH 10/10] Merge author param into Proposal building at proposal controller create action --- app/controllers/proposals_controller.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 33497dd26..8aa9fd0e6 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -23,11 +23,10 @@ class ProposalsController < ApplicationController end def create - @proposal = Proposal.new(proposal_params) - @proposal.author = current_user + @proposal = Proposal.new(proposal_params.merge(author: current_user)) if @proposal.save - redirect_to share_proposal_path(@proposal), notice: I18n.t("flash.actions.create.proposal") + redirect_to share_proposal_path(@proposal), notice: I18n.t('flash.actions.create.proposal') else render :new end