<%= t("proposals.proposal.proposal") %>
-
<%= link_to proposal.title, proposal %>
+
<%= link_to proposal.title, namespaced_proposal_path(proposal) %>
- <%= link_to t("proposals.proposal.comments", count: proposal.comments_count), proposal_path(proposal, anchor: "comments") %>
+ <%= link_to t("proposals.proposal.comments", count: proposal.comments_count), namespaced_proposal_path(proposal, anchor: "comments") %>
•
<%= l proposal.created_at.to_date %>
@@ -39,7 +39,7 @@
<% end %>
-
<%= link_to proposal.summary, proposal %>
+
<%= link_to proposal.summary, namespaced_proposal_path(proposal) %>
<%= render "shared/tags", taggable: proposal, limit: 5 %>
diff --git a/config/locales/management.en.yml b/config/locales/management.en.yml
index d698995df..936c9694d 100644
--- a/config/locales/management.en.yml
+++ b/config/locales/management.en.yml
@@ -47,7 +47,8 @@ en:
has_no_account_html: "In order to create an account, go to %{link} and click in
'Register' in the upper-left part of the screen."
verify: "Verify"
email_verifications:
- document_found_in_census: "This document was found in the census, but it has no user account associated to it. Please choose one of the following options:"
+ document_found_in_census: "This document was found in the census, but it has no user account associated to it."
+ choose_options: "Please choose one of the following options:"
if_existing_account: "If the person has already a user account created in the website,"
introduce_email: "Please introduce the email used on the account:"
email_placeholder: "Write the email this person used to create his or her account"
diff --git a/config/locales/management.es.yml b/config/locales/management.es.yml
index 67dc9e33a..da38ee209 100644
--- a/config/locales/management.es.yml
+++ b/config/locales/management.es.yml
@@ -47,7 +47,8 @@ es:
has_no_account_html: "Para crear un usuario entre en %{link} y haga clic en la opción
'Registrarse' en la parte superior derecha de la pantalla."
verify: "Verificar usuario"
email_verifications:
- document_found_in_census: "Este documento está en el registro del padrón municipal, pero todavía no tiene una cuenta de usuario asociada. Elige una de las opciones siguientes:"
+ document_found_in_census: "Este documento está en el registro del padrón municipal, pero todavía no tiene una cuenta de usuario asociada."
+ choose_options: "Elige una de las opciones siguientes:"
if_existing_account: "Si la persona ya ha creado una cuenta de usuario en la web"
introduce_email: "Introduce el email con el que creó la cuenta:"
email_placeholder: "Introduce el email de registro"
diff --git a/spec/controllers/management/base_controller_spec.rb b/spec/controllers/management/base_controller_spec.rb
new file mode 100644
index 000000000..0f4a95d7e
--- /dev/null
+++ b/spec/controllers/management/base_controller_spec.rb
@@ -0,0 +1,27 @@
+require 'rails_helper'
+
+describe Management::BaseController do
+
+ describe 'managed_user' do
+
+ it "should return existent user with session document info if present" do
+ session[:document_type] = "1"
+ session[:document_number] = "333333333E"
+ user = create(:user, :level_two, document_number: "333333333E")
+ managed_user = subject.send(:managed_user)
+
+ expect(managed_user).to eq user
+ end
+
+ it "should return new user if no user have the session document info" do
+ session[:document_type] = "1"
+ session[:document_number] = "333333333E"
+ managed_user = subject.send(:managed_user)
+
+ expect(managed_user).to be_new_record
+ expect(managed_user.document_type).to eq "1"
+ expect(managed_user.document_number).to eq "333333333E"
+ end
+ end
+
+end
\ No newline at end of file
diff --git a/spec/controllers/management/sessions_controller_spec.rb b/spec/controllers/management/sessions_controller_spec.rb
index f63cd3a56..af53f4ae0 100644
--- a/spec/controllers/management/sessions_controller_spec.rb
+++ b/spec/controllers/management/sessions_controller_spec.rb
@@ -18,12 +18,16 @@ describe Management::SessionsController do
end
describe 'Sign out' do
- it "should destroy the session and redirect" do
+ it "should destroy the session data and redirect" do
session[:manager] = {user_key: "31415926" , date: "20151031135905", login: "JJB033"}
+ session[:document_type] = "1"
+ session[:document_number] = "12345678Z"
delete :destroy
expect(session[:manager]).to be_nil
+ expect(session[:document_type]).to be_nil
+ expect(session[:document_number]).to be_nil
expect(response).to be_redirect
end
end
diff --git a/spec/controllers/management/users_controller_spec.rb b/spec/controllers/management/users_controller_spec.rb
new file mode 100644
index 000000000..ed73aa053
--- /dev/null
+++ b/spec/controllers/management/users_controller_spec.rb
@@ -0,0 +1,20 @@
+require 'rails_helper'
+
+describe Management::UsersController do
+
+ describe 'logout' do
+ it "should remove user data from the session" do
+ session[:manager] = {user_key: "31415926" , date: "20151031135905", login: "JJB033"}
+ session[:document_type] = "1"
+ session[:document_number] = "12345678Z"
+
+ get :logout
+
+ expect(session[:manager]).to eq({user_key: "31415926" , date: "20151031135905", login: "JJB033"})
+ expect(session[:document_type]).to be_nil
+ expect(session[:document_number]).to be_nil
+ expect(response).to be_redirect
+ end
+ end
+
+end
\ No newline at end of file
diff --git a/spec/features/management/localization_spec.rb b/spec/features/management/localization_spec.rb
new file mode 100644
index 000000000..ba4d7f27f
--- /dev/null
+++ b/spec/features/management/localization_spec.rb
@@ -0,0 +1,48 @@
+require 'rails_helper'
+
+feature 'Localization' do
+
+ background do
+ login_as_manager
+ end
+
+ scenario 'Wrong locale' do
+ visit management_root_path(locale: :es)
+ visit management_root_path(locale: :klingon)
+
+ expect(page).to have_text('Gestión')
+ end
+
+ scenario 'Available locales appear in the locale switcher' do
+ visit management_root_path
+
+ within('.locale-form .js-location-changer') do
+ expect(page).to have_content 'Español'
+ expect(page).to have_content 'English'
+ end
+ end
+
+ scenario 'The current locale is selected' do
+ visit management_root_path
+ expect(page).to have_select('locale-switcher', selected: 'English')
+ expect(page).to have_text('Management')
+ end
+
+ scenario 'Changing the locale', :js do
+ visit management_root_path
+ expect(page).to have_content('Language')
+
+ select('Español', from: 'locale-switcher')
+ expect(page).to have_content('Idioma')
+ expect(page).to_not have_content('Language')
+ expect(page).to have_select('locale-switcher', selected: 'Español')
+ end
+
+ scenario 'Locale switcher not present if only one locale' do
+ expect(I18n).to receive(:available_locales).and_return([:en])
+
+ visit management_root_path
+ expect(page).to_not have_content('Language')
+ expect(page).to_not have_css('div.locale')
+ end
+end
\ No newline at end of file
diff --git a/spec/features/management/managed_users_spec.rb b/spec/features/management/managed_users_spec.rb
index b4d94ca40..78010bc39 100644
--- a/spec/features/management/managed_users_spec.rb
+++ b/spec/features/management/managed_users_spec.rb
@@ -8,6 +8,11 @@ feature 'Managed User' do
context "Currently managed user" do
+ scenario "No managed user" do
+ visit management_document_verifications_path
+ expect(page).not_to have_css ".account-info"
+ end
+
scenario "User is already level three verified" do
user = create(:user, :level_three)
@@ -55,6 +60,15 @@ feature 'Managed User' do
fill_in 'document_verification_document_number', with: '1234'
click_button 'Check'
+ within(".account-info") do
+ expect(page).not_to have_content "Identified as"
+ expect(page).not_to have_content "Username"
+ expect(page).not_to have_content "Email"
+ expect(page).to have_content "Document type"
+ expect(page).to have_content "Document number"
+ expect(page).to have_content "1234"
+ end
+
expect(page).to have_content "Please introduce the email used on the account"
fill_in 'email_verification_email', with: user.email
@@ -115,6 +129,8 @@ feature 'Managed User' do
end
expect(page).to have_content "User session signed out successfully."
+ expect(page).to_not have_content "Identified as"
+ expect(page).to_not have_content "#{user.username}"
expect(current_path).to eq(management_root_path)
end
diff --git a/spec/features/management/proposals_spec.rb b/spec/features/management/proposals_spec.rb
index 46411c7af..2764efca7 100644
--- a/spec/features/management/proposals_spec.rb
+++ b/spec/features/management/proposals_spec.rb
@@ -14,6 +14,13 @@ feature 'Proposals' do
click_link "Create proposal"
+ within(".account-info") do
+ expect(page).to have_content "Identified as"
+ expect(page).to have_content "#{user.username}"
+ expect(page).to have_content "#{user.email}"
+ expect(page).to have_content "#{user.document_number}"
+ end
+
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...'
@@ -36,7 +43,7 @@ feature 'Proposals' do
expect(page).to have_content user.name
expect(page).to have_content I18n.l(Proposal.last.created_at.to_date)
- expect(URI.parse(current_url).path).to eq(management_proposal_path(Proposal.last))
+ expect(current_path).to eq(management_proposal_path(Proposal.last))
end
scenario "Should not allow unverified users to create proposals" do
@@ -49,9 +56,59 @@ feature 'Proposals' do
end
end
+ scenario "Searching" do
+ proposal1 = create(:proposal, title: "Show me what you got")
+ proposal2 = create(:proposal, title: "Get Schwifty")
+
+ user = create(:user, :level_two)
+ login_managed_user(user)
+
+ click_link "Support proposals"
+
+ fill_in "search", with: "what you got"
+ click_button "Search"
+
+ expect(current_path).to eq(management_proposals_path)
+
+ within("#proposals") do
+ expect(page).to have_css('.proposal', count: 1)
+ expect(page).to have_content(proposal1.title)
+ expect(page).to_not have_content(proposal2.title)
+ expect(page).to have_css("a[href='#{management_proposal_path(proposal1)}']", text: proposal1.title)
+ expect(page).to have_css("a[href='#{management_proposal_path(proposal1)}']", text: proposal1.summary)
+ end
+ end
+
+ scenario "Listing" do
+ proposal1 = create(:proposal, title: "Show me what you got")
+ proposal2 = create(:proposal, title: "Get Schwifty")
+
+ user = create(:user, :level_two)
+ login_managed_user(user)
+
+ click_link "Support proposals"
+
+ expect(current_path).to eq(management_proposals_path)
+
+ within(".account-info") do
+ expect(page).to have_content "Identified as"
+ expect(page).to have_content "#{user.username}"
+ expect(page).to have_content "#{user.email}"
+ expect(page).to have_content "#{user.document_number}"
+ end
+
+ within("#proposals") do
+ expect(page).to have_css('.proposal', count: 2)
+ expect(page).to have_css("a[href='#{management_proposal_path(proposal1)}']", text: proposal1.title)
+ expect(page).to have_css("a[href='#{management_proposal_path(proposal1)}']", text: proposal1.summary)
+ expect(page).to have_css("a[href='#{management_proposal_path(proposal2)}']", text: proposal2.title)
+ expect(page).to have_css("a[href='#{management_proposal_path(proposal2)}']", text: proposal2.summary)
+ end
+ end
+
context "Voting" do
- scenario 'Voting proposals on behalf of someone', :js do
+ scenario 'Voting proposals on behalf of someone in index view', :js do
proposal = create(:proposal)
user = create(:user, :level_two)
@@ -65,7 +122,25 @@ feature 'Proposals' do
expect(page).to have_content "1 support"
expect(page).to have_content "You already supported this proposal"
end
- expect(URI.parse(current_url).path).to eq(management_proposals_path)
+ expect(current_path).to eq(management_proposals_path)
+ end
+
+ scenario 'Voting proposals on behalf of someone in show view', :js do
+ proposal = create(:proposal)
+
+ user = create(:user, :level_two)
+ login_managed_user(user)
+
+ click_link "Support proposals"
+
+ within("#proposals") do
+ click_link proposal.title
+ end
+
+ find('.in-favor a').click
+ expect(page).to have_content "1 support"
+ expect(page).to have_content "You already supported this proposal"
+ expect(current_path).to eq(management_proposal_path(proposal))
end
scenario "Should not allow unverified users to vote proposals" do
@@ -78,27 +153,6 @@ feature 'Proposals' do
expect(page).to have_content "User is not verified"
end
-
- scenario "Searching" do
- proposal1 = create(:proposal, title: "Show me what you got")
- proposal2 = create(:proposal, title: "Get Schwifty")
-
- user = create(:user, :level_two)
- login_managed_user(user)
-
- click_link "Support proposals"
-
- fill_in "search", with: "what you got"
- click_button "Search"
-
- expect(current_path).to eq(management_proposals_path)
-
- within("#proposals") do
- expect(page).to have_css('.proposal', count: 1)
- expect(page).to have_content(proposal1.title)
- expect(page).to_not have_content(proposal2.title)
- end
- end
end
context "Printing" do
diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb
index 8706afd42..5b83e37b3 100644
--- a/spec/features/proposals_spec.rb
+++ b/spec/features/proposals_spec.rb
@@ -20,6 +20,7 @@ feature 'Proposals' do
proposals.each do |proposal|
within('#proposals') do
expect(page).to have_content proposal.title
+ expect(page).to have_css("a[href='#{proposal_path(proposal)}']", text: proposal.title)
expect(page).to have_css("a[href='#{proposal_path(proposal)}']", text: proposal.summary)
end
end
diff --git a/spec/features/votes_spec.rb b/spec/features/votes_spec.rb
index 06f7ad4c9..31498191a 100644
--- a/spec/features/votes_spec.rb
+++ b/spec/features/votes_spec.rb
@@ -260,7 +260,7 @@ feature 'Votes' do
expect(page).to have_content "1 support"
expect(page).to have_content "You already supported this proposal, share it!"
end
- expect(URI.parse(current_url).path).to eq(proposals_path)
+ expect(current_path).to eq(proposals_path)
end
scenario 'Create in featured proposal in index', :js do
@@ -271,7 +271,7 @@ feature 'Votes' do
expect(page).to have_content "You already supported this proposal, share it!"
end
- expect(URI.parse(current_url).path).to eq(proposals_path)
+ expect(current_path).to eq(proposals_path)
end
end
end