From 17d6b55fb3e19d55be882311e03a32eadf42a2ec Mon Sep 17 00:00:00 2001 From: rgarcia Date: Sun, 21 Feb 2016 18:04:11 +0100 Subject: [PATCH] adds notice with html after spending proposal creation --- .../spending_proposals_controller.rb | 4 ++- app/views/layouts/application.html.erb | 4 +-- config/locales/responders.en.yml | 2 +- config/locales/responders.es.yml | 2 +- spec/features/spending_proposals_spec.rb | 26 +++++++++++++++++++ 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/app/controllers/spending_proposals_controller.rb b/app/controllers/spending_proposals_controller.rb index 17b7ad738..3965c7494 100644 --- a/app/controllers/spending_proposals_controller.rb +++ b/app/controllers/spending_proposals_controller.rb @@ -5,6 +5,7 @@ class SpendingProposalsController < ApplicationController before_action :authenticate_user!, except: [:index] before_action :verify_access, only: [:show] + before_filter -> { flash.now[:notice] = flash[:notice].html_safe if flash[:html_safe] && flash[:notice] } feature_flag :spending_proposals @@ -20,7 +21,8 @@ class SpendingProposalsController < ApplicationController @spending_proposal.author = current_user if @spending_proposal.save_with_captcha - redirect_to @spending_proposal, notice: t("flash.actions.create.spending_proposal") + notice = t('flash.actions.create.spending_proposal', activity: "#{t('layouts.header.my_activity_link')}"), flash: { html_safe: true } + redirect_to @spending_proposal, notice: notice else render :new end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index fd95e30f1..22fd97143 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -41,7 +41,7 @@ <% if notice %> -
+
">× @@ -52,7 +52,7 @@ <% end %> <% if alert %> -
+
">× diff --git a/config/locales/responders.en.yml b/config/locales/responders.en.yml index 47c437119..b2640c6ac 100755 --- a/config/locales/responders.en.yml +++ b/config/locales/responders.en.yml @@ -6,7 +6,7 @@ en: notice: "%{resource_name} created successfully." debate: "Debate created successfully." proposal: "Proposal created successfully." - spending_proposal: "Spending proposal created successfully." + spending_proposal: "Spending proposal created successfully. You can access it from %{activity}" save_changes: notice: Changes saved update: diff --git a/config/locales/responders.es.yml b/config/locales/responders.es.yml index 8dcb11db7..5c22856cc 100644 --- a/config/locales/responders.es.yml +++ b/config/locales/responders.es.yml @@ -6,7 +6,7 @@ es: notice: "%{resource_name} creado correctamente." debate: "Debate creado correctamente." proposal: "Propuesta creada correctamente." - spending_proposal: "Propuesta de gasto creada correctamente." + spending_proposal: "Propuesta de inversión creada correctamente. Puedes acceder a ella desde %{activity}" save_changes: notice: Cambios guardados update: diff --git a/spec/features/spending_proposals_spec.rb b/spec/features/spending_proposals_spec.rb index 484444fbb..12d692fcf 100644 --- a/spec/features/spending_proposals_spec.rb +++ b/spec/features/spending_proposals_spec.rb @@ -40,6 +40,32 @@ feature 'Spending proposals' do expect(page).to have_content('All city') end + scenario 'Create notice' do + login_as(author) + + visit new_spending_proposal_path + fill_in 'spending_proposal_title', with: 'Build a skyscraper' + fill_in 'spending_proposal_description', with: 'I want to live in a high tower over the clouds' + fill_in 'spending_proposal_external_url', with: 'http://http://skyscraperpage.com/' + fill_in 'spending_proposal_association_name', with: 'People of the neighbourhood' + fill_in 'spending_proposal_captcha', with: correct_captcha_text + select 'All city', from: 'spending_proposal_geozone_id' + check 'spending_proposal_terms_of_service' + + click_button 'Create' + + expect(page).to have_content 'Spending proposal created successfully' + expect(page).to have_content 'You can access it from My activity' + + within "#notice" do + click_link 'My activity' + end + + expect(current_url).to eq(user_url(author, filter: :spending_proposals)) + expect(page).to have_content "1 Spending proposal" + expect(page).to have_content "Build a skyscraper" + end + scenario 'Captcha is required for proposal creation' do login_as(author)