adds notice with html after spending proposal creation

This commit is contained in:
rgarcia
2016-02-21 18:04:11 +01:00
parent 7699b99655
commit 17d6b55fb3
5 changed files with 33 additions and 5 deletions

View File

@@ -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: "<a href='#{user_path(current_user, filter: :spending_proposals)}'>#{t('layouts.header.my_activity_link')}</a>"), flash: { html_safe: true }
redirect_to @spending_proposal, notice: notice
else
render :new
end

View File

@@ -41,7 +41,7 @@
<![endif]-->
<% if notice %>
<div class="alert-messages">
<div id="notice" class="alert-messages">
<div class="row">
<div data-alert class="alert-box success radius">
<a href="#" class="close" title="<%= t("application.close") %>">&times;</a>
@@ -52,7 +52,7 @@
<% end %>
<% if alert %>
<div class="alert-messages">
<div id="alert" class="alert-messages">
<div class="row">
<div data-alert class="alert-box alert radius">
<a href="#" class="close" title="<%= t("application.close") %>">&times;</a>

View File

@@ -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:

View File

@@ -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:

View File

@@ -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)