adds notice with html after spending proposal creation
This commit is contained in:
@@ -5,6 +5,7 @@ class SpendingProposalsController < ApplicationController
|
|||||||
|
|
||||||
before_action :authenticate_user!, except: [:index]
|
before_action :authenticate_user!, except: [:index]
|
||||||
before_action :verify_access, only: [:show]
|
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
|
feature_flag :spending_proposals
|
||||||
|
|
||||||
@@ -20,7 +21,8 @@ class SpendingProposalsController < ApplicationController
|
|||||||
@spending_proposal.author = current_user
|
@spending_proposal.author = current_user
|
||||||
|
|
||||||
if @spending_proposal.save_with_captcha
|
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
|
else
|
||||||
render :new
|
render :new
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
||||||
<% if notice %>
|
<% if notice %>
|
||||||
<div class="alert-messages">
|
<div id="notice" class="alert-messages">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div data-alert class="alert-box success radius">
|
<div data-alert class="alert-box success radius">
|
||||||
<a href="#" class="close" title="<%= t("application.close") %>">×</a>
|
<a href="#" class="close" title="<%= t("application.close") %>">×</a>
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if alert %>
|
<% if alert %>
|
||||||
<div class="alert-messages">
|
<div id="alert" class="alert-messages">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div data-alert class="alert-box alert radius">
|
<div data-alert class="alert-box alert radius">
|
||||||
<a href="#" class="close" title="<%= t("application.close") %>">×</a>
|
<a href="#" class="close" title="<%= t("application.close") %>">×</a>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ en:
|
|||||||
notice: "%{resource_name} created successfully."
|
notice: "%{resource_name} created successfully."
|
||||||
debate: "Debate created successfully."
|
debate: "Debate created successfully."
|
||||||
proposal: "Proposal 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:
|
save_changes:
|
||||||
notice: Changes saved
|
notice: Changes saved
|
||||||
update:
|
update:
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ es:
|
|||||||
notice: "%{resource_name} creado correctamente."
|
notice: "%{resource_name} creado correctamente."
|
||||||
debate: "Debate creado correctamente."
|
debate: "Debate creado correctamente."
|
||||||
proposal: "Propuesta creada 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:
|
save_changes:
|
||||||
notice: Cambios guardados
|
notice: Cambios guardados
|
||||||
update:
|
update:
|
||||||
|
|||||||
@@ -40,6 +40,32 @@ feature 'Spending proposals' do
|
|||||||
expect(page).to have_content('All city')
|
expect(page).to have_content('All city')
|
||||||
end
|
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
|
scenario 'Captcha is required for proposal creation' do
|
||||||
login_as(author)
|
login_as(author)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user