Sign in manager after setting up test data
We've got quite a messy hack to sign in managers: they need to visit a specific URL (management root path). That means tests signing in managers start the browser to sign them in, which might cause issues if we setup the database after that.
This commit is contained in:
@@ -282,12 +282,12 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name,
|
|||||||
describe "At #{mappable_show_path}" do
|
describe "At #{mappable_show_path}" do
|
||||||
before do
|
before do
|
||||||
set_arguments(arguments, mappable, mappable_path_arguments)
|
set_arguments(arguments, mappable, mappable_path_arguments)
|
||||||
do_login_for(user) if management
|
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Should display map and marker on #{mappable_factory_name} show page" do
|
scenario "Should display map and marker on #{mappable_factory_name} show page" do
|
||||||
arguments[:id] = mappable.id
|
arguments[:id] = mappable.id
|
||||||
|
|
||||||
|
do_login_for(user) if management
|
||||||
visit send(mappable_show_path, arguments)
|
visit send(mappable_show_path, arguments)
|
||||||
|
|
||||||
within ".map_location" do
|
within ".map_location" do
|
||||||
@@ -300,6 +300,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name,
|
|||||||
set_arguments(arguments, mappable_without_map, mappable_path_arguments)
|
set_arguments(arguments, mappable_without_map, mappable_path_arguments)
|
||||||
arguments[:id] = mappable_without_map.id
|
arguments[:id] = mappable_without_map.id
|
||||||
|
|
||||||
|
do_login_for(user) if management
|
||||||
visit send(mappable_show_path, arguments)
|
visit send(mappable_show_path, arguments)
|
||||||
|
|
||||||
expect(page).not_to have_css(".map_location")
|
expect(page).not_to have_css(".map_location")
|
||||||
@@ -309,6 +310,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name,
|
|||||||
Setting["feature.map"] = false
|
Setting["feature.map"] = false
|
||||||
arguments[:id] = mappable.id
|
arguments[:id] = mappable.id
|
||||||
|
|
||||||
|
do_login_for(user) if management
|
||||||
visit send(mappable_show_path, arguments)
|
visit send(mappable_show_path, arguments)
|
||||||
|
|
||||||
expect(page).not_to have_css(".map_location")
|
expect(page).not_to have_css(".map_location")
|
||||||
@@ -318,8 +320,8 @@ end
|
|||||||
|
|
||||||
def do_login_for(user)
|
def do_login_for(user)
|
||||||
if management
|
if management
|
||||||
login_as_manager
|
|
||||||
login_managed_user(user)
|
login_managed_user(user)
|
||||||
|
login_as_manager
|
||||||
else
|
else
|
||||||
login_as(user)
|
login_as(user)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,16 +1,11 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
describe "Account" do
|
describe "Account" do
|
||||||
before do
|
|
||||||
login_as_manager
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Should not allow unverified users to edit their account" do
|
scenario "Should not allow unverified users to edit their account" do
|
||||||
user = create(:user)
|
user = create(:user)
|
||||||
login_managed_user(user)
|
login_managed_user(user)
|
||||||
|
|
||||||
visit management_root_path
|
login_as_manager
|
||||||
|
|
||||||
click_link "Reset password via email"
|
click_link "Reset password via email"
|
||||||
|
|
||||||
expect(page).to have_content "No verified user logged in yet"
|
expect(page).to have_content "No verified user logged in yet"
|
||||||
@@ -20,6 +15,7 @@ describe "Account" do
|
|||||||
user = create(:user, :level_two)
|
user = create(:user, :level_two)
|
||||||
login_managed_user(user)
|
login_managed_user(user)
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
visit management_account_path
|
visit management_account_path
|
||||||
|
|
||||||
click_link "Delete user"
|
click_link "Delete user"
|
||||||
@@ -33,8 +29,8 @@ describe "Account" do
|
|||||||
scenario "Send reset password email to currently managed user session" do
|
scenario "Send reset password email to currently managed user session" do
|
||||||
user = create(:user, :level_three)
|
user = create(:user, :level_three)
|
||||||
login_managed_user(user)
|
login_managed_user(user)
|
||||||
visit management_root_path
|
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
click_link "Reset password via email"
|
click_link "Reset password via email"
|
||||||
|
|
||||||
click_link "Send reset password email"
|
click_link "Send reset password email"
|
||||||
@@ -49,8 +45,8 @@ describe "Account" do
|
|||||||
scenario "Manager changes the password by hand (writen by them)" do
|
scenario "Manager changes the password by hand (writen by them)" do
|
||||||
user = create(:user, :level_three)
|
user = create(:user, :level_three)
|
||||||
login_managed_user(user)
|
login_managed_user(user)
|
||||||
visit management_root_path
|
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
click_link "Reset password manually"
|
click_link "Reset password manually"
|
||||||
|
|
||||||
find(:css, "input[id$='user_password']").set("new_password")
|
find(:css, "input[id$='user_password']").set("new_password")
|
||||||
@@ -69,8 +65,8 @@ describe "Account" do
|
|||||||
scenario "Manager generates random password" do
|
scenario "Manager generates random password" do
|
||||||
user = create(:user, :level_three)
|
user = create(:user, :level_three)
|
||||||
login_managed_user(user)
|
login_managed_user(user)
|
||||||
visit management_root_path
|
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
click_link "Reset password manually"
|
click_link "Reset password manually"
|
||||||
click_link "Generate random password"
|
click_link "Generate random password"
|
||||||
|
|
||||||
@@ -90,8 +86,8 @@ describe "Account" do
|
|||||||
scenario "The password is printed" do
|
scenario "The password is printed" do
|
||||||
user = create(:user, :level_three)
|
user = create(:user, :level_three)
|
||||||
login_managed_user(user)
|
login_managed_user(user)
|
||||||
visit management_root_path
|
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
click_link "Reset password manually"
|
click_link "Reset password manually"
|
||||||
|
|
||||||
find(:css, "input[id$='user_password']").set("another_new_password")
|
find(:css, "input[id$='user_password']").set("another_new_password")
|
||||||
|
|||||||
@@ -7,10 +7,7 @@ describe "Budget Investments" do
|
|||||||
let(:heading) { create(:budget_heading, group: group, name: "Health") }
|
let(:heading) { create(:budget_heading, group: group, name: "Health") }
|
||||||
let(:user) { create(:user, :level_two) }
|
let(:user) { create(:user, :level_two) }
|
||||||
|
|
||||||
before do
|
before { login_managed_user(user) }
|
||||||
login_managed_user(user)
|
|
||||||
login_as_manager(manager)
|
|
||||||
end
|
|
||||||
|
|
||||||
it_behaves_like "mappable",
|
it_behaves_like "mappable",
|
||||||
"budget_investment",
|
"budget_investment",
|
||||||
@@ -25,6 +22,7 @@ describe "Budget Investments" do
|
|||||||
let(:investment) { create(:budget_investment, budget: budget) }
|
let(:investment) { create(:budget_investment, budget: budget) }
|
||||||
|
|
||||||
scenario "finds investment using budget slug" do
|
scenario "finds investment using budget slug" do
|
||||||
|
login_as_manager(manager)
|
||||||
visit management_budget_investment_path("budget_slug", investment)
|
visit management_budget_investment_path("budget_slug", investment)
|
||||||
|
|
||||||
expect(page).to have_content investment.title
|
expect(page).to have_content investment.title
|
||||||
@@ -35,6 +33,7 @@ describe "Budget Investments" do
|
|||||||
before { heading.budget.update(phase: "accepting") }
|
before { heading.budget.update(phase: "accepting") }
|
||||||
|
|
||||||
scenario "Creating budget investments on behalf of someone, selecting a budget" do
|
scenario "Creating budget investments on behalf of someone, selecting a budget" do
|
||||||
|
login_as_manager(manager)
|
||||||
click_link "Create budget investment"
|
click_link "Create budget investment"
|
||||||
within "#budget_#{budget.id}" do
|
within "#budget_#{budget.id}" do
|
||||||
click_link "Create budget investment"
|
click_link "Create budget investment"
|
||||||
@@ -71,6 +70,7 @@ describe "Budget Investments" do
|
|||||||
scenario "Should not allow unverified users to create budget investments" do
|
scenario "Should not allow unverified users to create budget investments" do
|
||||||
login_managed_user(create(:user))
|
login_managed_user(create(:user))
|
||||||
|
|
||||||
|
login_as_manager(manager)
|
||||||
click_link "Create budget investment"
|
click_link "Create budget investment"
|
||||||
|
|
||||||
expect(page).to have_content "User is not verified"
|
expect(page).to have_content "User is not verified"
|
||||||
@@ -83,6 +83,7 @@ describe "Budget Investments" do
|
|||||||
create(:budget_investment, budget: budget, title: "No more parks")
|
create(:budget_investment, budget: budget, title: "No more parks")
|
||||||
create(:budget_investment, budget: budget, title: "Plant trees")
|
create(:budget_investment, budget: budget, title: "Plant trees")
|
||||||
|
|
||||||
|
login_as_manager(manager)
|
||||||
click_link "Create budget investment"
|
click_link "Create budget investment"
|
||||||
within "#budget_#{budget.id}" do
|
within "#budget_#{budget.id}" do
|
||||||
click_link "Create budget investment"
|
click_link "Create budget investment"
|
||||||
@@ -104,6 +105,7 @@ describe "Budget Investments" do
|
|||||||
budget_investment1 = create(:budget_investment, budget: budget, title: "Show me what you got")
|
budget_investment1 = create(:budget_investment, budget: budget, title: "Show me what you got")
|
||||||
budget_investment2 = create(:budget_investment, budget: budget, title: "Get Schwifty")
|
budget_investment2 = create(:budget_investment, budget: budget, title: "Get Schwifty")
|
||||||
|
|
||||||
|
login_as_manager(manager)
|
||||||
click_link "Support budget investments"
|
click_link "Support budget investments"
|
||||||
expect(page).to have_content(budget.name)
|
expect(page).to have_content(budget.name)
|
||||||
within "#budget_#{budget.id}" do
|
within "#budget_#{budget.id}" do
|
||||||
@@ -129,6 +131,7 @@ describe "Budget Investments" do
|
|||||||
budget_investment2 = create(:budget_investment, budget: budget, title: "Let's go",
|
budget_investment2 = create(:budget_investment, budget: budget, title: "Let's go",
|
||||||
heading: create(:budget_heading, name: "Area 52"))
|
heading: create(:budget_heading, name: "Area 52"))
|
||||||
|
|
||||||
|
login_as_manager(manager)
|
||||||
click_link "Support budget investments"
|
click_link "Support budget investments"
|
||||||
expect(page).to have_content(budget.name)
|
expect(page).to have_content(budget.name)
|
||||||
within "#budget_#{budget.id}" do
|
within "#budget_#{budget.id}" do
|
||||||
@@ -153,6 +156,7 @@ describe "Budget Investments" do
|
|||||||
budget_investment1 = create(:budget_investment, budget: budget, title: "Show me what you got")
|
budget_investment1 = create(:budget_investment, budget: budget, title: "Show me what you got")
|
||||||
budget_investment2 = create(:budget_investment, budget: budget, title: "Get Schwifty")
|
budget_investment2 = create(:budget_investment, budget: budget, title: "Get Schwifty")
|
||||||
|
|
||||||
|
login_as_manager(manager)
|
||||||
click_link "Support budget investments"
|
click_link "Support budget investments"
|
||||||
expect(page).to have_content(budget.name)
|
expect(page).to have_content(budget.name)
|
||||||
within "#budget_#{budget.id}" do
|
within "#budget_#{budget.id}" do
|
||||||
@@ -186,6 +190,7 @@ describe "Budget Investments" do
|
|||||||
reviewing_ballots_budget = create(:budget, :reviewing_ballots)
|
reviewing_ballots_budget = create(:budget, :reviewing_ballots)
|
||||||
finished = create(:budget, :finished)
|
finished = create(:budget, :finished)
|
||||||
|
|
||||||
|
login_as_manager(manager)
|
||||||
click_link "Create budget investment"
|
click_link "Create budget investment"
|
||||||
|
|
||||||
expect(page).to have_content(accepting_budget.name)
|
expect(page).to have_content(accepting_budget.name)
|
||||||
@@ -207,11 +212,7 @@ describe "Budget Investments" do
|
|||||||
reviewing_ballots_budget = create(:budget, :reviewing_ballots)
|
reviewing_ballots_budget = create(:budget, :reviewing_ballots)
|
||||||
finished = create(:budget, :finished)
|
finished = create(:budget, :finished)
|
||||||
|
|
||||||
visit root_path
|
login_as(create(:administrator).user)
|
||||||
click_link "Sign out"
|
|
||||||
|
|
||||||
admin = create(:administrator)
|
|
||||||
login_as(admin.user)
|
|
||||||
|
|
||||||
visit management_sign_in_path
|
visit management_sign_in_path
|
||||||
|
|
||||||
@@ -231,6 +232,7 @@ describe "Budget Investments" do
|
|||||||
scenario "Supporting budget investments on behalf of someone in index view" do
|
scenario "Supporting budget investments on behalf of someone in index view" do
|
||||||
budget_investment = create(:budget_investment, heading: heading)
|
budget_investment = create(:budget_investment, heading: heading)
|
||||||
|
|
||||||
|
login_as_manager(manager)
|
||||||
click_link "Support budget investments"
|
click_link "Support budget investments"
|
||||||
expect(page).to have_content(budget.name)
|
expect(page).to have_content(budget.name)
|
||||||
within "#budget_#{budget.id}" do
|
within "#budget_#{budget.id}" do
|
||||||
@@ -250,6 +252,7 @@ describe "Budget Investments" do
|
|||||||
xscenario "Supporting budget investments on behalf of someone in show view" do
|
xscenario "Supporting budget investments on behalf of someone in show view" do
|
||||||
budget_investment = create(:budget_investment, budget: budget)
|
budget_investment = create(:budget_investment, budget: budget)
|
||||||
|
|
||||||
|
login_as_manager(manager)
|
||||||
click_link "Support budget investments"
|
click_link "Support budget investments"
|
||||||
expect(page).to have_content(budget.name)
|
expect(page).to have_content(budget.name)
|
||||||
within "#budget_#{budget.id}" do
|
within "#budget_#{budget.id}" do
|
||||||
@@ -269,6 +272,7 @@ describe "Budget Investments" do
|
|||||||
login_managed_user(create(:user))
|
login_managed_user(create(:user))
|
||||||
create(:budget_investment, budget: budget)
|
create(:budget_investment, budget: budget)
|
||||||
|
|
||||||
|
login_as_manager(manager)
|
||||||
click_link "Support budget investments"
|
click_link "Support budget investments"
|
||||||
|
|
||||||
expect(page).to have_content "User is not verified"
|
expect(page).to have_content "User is not verified"
|
||||||
@@ -279,6 +283,7 @@ describe "Budget Investments" do
|
|||||||
scenario "Printing budget investments" do
|
scenario "Printing budget investments" do
|
||||||
16.times { create(:budget_investment, heading: heading) }
|
16.times { create(:budget_investment, heading: heading) }
|
||||||
|
|
||||||
|
login_as_manager(manager)
|
||||||
click_link "Print budget investments"
|
click_link "Print budget investments"
|
||||||
|
|
||||||
expect(page).to have_content(budget.name)
|
expect(page).to have_content(budget.name)
|
||||||
@@ -295,6 +300,7 @@ describe "Budget Investments" do
|
|||||||
|
|
||||||
voted_investment = create(:budget_investment, :selected, heading: heading, balloters: [create(:user)])
|
voted_investment = create(:budget_investment, :selected, heading: heading, balloters: [create(:user)])
|
||||||
|
|
||||||
|
login_as_manager(manager)
|
||||||
click_link "Print budget investments"
|
click_link "Print budget investments"
|
||||||
|
|
||||||
within "#budget_#{budget.id}" do
|
within "#budget_#{budget.id}" do
|
||||||
@@ -328,6 +334,7 @@ describe "Budget Investments" do
|
|||||||
heading: another_heading,
|
heading: another_heading,
|
||||||
title: "Add new districts to the city")
|
title: "Add new districts to the city")
|
||||||
|
|
||||||
|
login_as_manager(manager)
|
||||||
click_link "Print budget investments"
|
click_link "Print budget investments"
|
||||||
|
|
||||||
expect(page).to have_content(budget.name)
|
expect(page).to have_content(budget.name)
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
describe "DocumentVerifications" do
|
describe "DocumentVerifications" do
|
||||||
before do
|
|
||||||
login_as_manager
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Verifying a level 3 user shows an 'already verified' page" do
|
scenario "Verifying a level 3 user shows an 'already verified' page" do
|
||||||
user = create(:user, :level_three)
|
user = create(:user, :level_three)
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
visit management_document_verifications_path
|
visit management_document_verifications_path
|
||||||
fill_in "document_verification_document_number", with: user.document_number
|
fill_in "document_verification_document_number", with: user.document_number
|
||||||
click_button "Check document"
|
click_button "Check document"
|
||||||
@@ -18,6 +15,7 @@ describe "DocumentVerifications" do
|
|||||||
scenario "Verifying a level 2 user displays the verification form" do
|
scenario "Verifying a level 2 user displays the verification form" do
|
||||||
user = create(:user, :level_two)
|
user = create(:user, :level_two)
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
visit management_document_verifications_path
|
visit management_document_verifications_path
|
||||||
fill_in "document_verification_document_number", with: user.document_number
|
fill_in "document_verification_document_number", with: user.document_number
|
||||||
click_button "Check document"
|
click_button "Check document"
|
||||||
@@ -37,6 +35,7 @@ describe "DocumentVerifications" do
|
|||||||
expect_any_instance_of(Verification::Management::Document).to receive(:in_census?).
|
expect_any_instance_of(Verification::Management::Document).to receive(:in_census?).
|
||||||
and_return(false)
|
and_return(false)
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
visit management_document_verifications_path
|
visit management_document_verifications_path
|
||||||
fill_in "document_verification_document_number", with: "inexisting"
|
fill_in "document_verification_document_number", with: "inexisting"
|
||||||
click_button "Check document"
|
click_button "Check document"
|
||||||
@@ -45,6 +44,7 @@ describe "DocumentVerifications" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Verifying a user which does exists in the census but not in the db redirects allows sending an email" do
|
scenario "Verifying a user which does exists in the census but not in the db redirects allows sending an email" do
|
||||||
|
login_as_manager
|
||||||
visit management_document_verifications_path
|
visit management_document_verifications_path
|
||||||
fill_in "document_verification_document_number", with: "12345678Z"
|
fill_in "document_verification_document_number", with: "12345678Z"
|
||||||
click_button "Check document"
|
click_button "Check document"
|
||||||
@@ -58,6 +58,7 @@ describe "DocumentVerifications" do
|
|||||||
expect_any_instance_of(Verification::Management::Document).to receive(:in_census?).
|
expect_any_instance_of(Verification::Management::Document).to receive(:in_census?).
|
||||||
and_return(false)
|
and_return(false)
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
visit management_document_verifications_path
|
visit management_document_verifications_path
|
||||||
fill_in "document_verification_document_number", with: "12345678Z"
|
fill_in "document_verification_document_number", with: "12345678Z"
|
||||||
select_date "31-December-1980", from: "document_verification_date_of_birth"
|
select_date "31-December-1980", from: "document_verification_date_of_birth"
|
||||||
@@ -71,6 +72,7 @@ describe "DocumentVerifications" do
|
|||||||
redirects allows sending an email" do
|
redirects allows sending an email" do
|
||||||
mock_valid_remote_census_response
|
mock_valid_remote_census_response
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
visit management_document_verifications_path
|
visit management_document_verifications_path
|
||||||
fill_in "document_verification_document_number", with: "12345678Z"
|
fill_in "document_verification_document_number", with: "12345678Z"
|
||||||
select_date "31-December-1980", from: "document_verification_date_of_birth"
|
select_date "31-December-1980", from: "document_verification_date_of_birth"
|
||||||
@@ -83,6 +85,7 @@ describe "DocumentVerifications" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Document number is format-standarized" do
|
scenario "Document number is format-standarized" do
|
||||||
|
login_as_manager
|
||||||
visit management_document_verifications_path
|
visit management_document_verifications_path
|
||||||
fill_in "document_verification_document_number", with: "12345 - h"
|
fill_in "document_verification_document_number", with: "12345 - h"
|
||||||
click_button "Check document"
|
click_button "Check document"
|
||||||
@@ -93,6 +96,7 @@ describe "DocumentVerifications" do
|
|||||||
scenario "User age is checked" do
|
scenario "User age is checked" do
|
||||||
expect_any_instance_of(Verification::Management::Document).to receive(:under_age?).and_return(true)
|
expect_any_instance_of(Verification::Management::Document).to receive(:under_age?).and_return(true)
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
visit management_document_verifications_path
|
visit management_document_verifications_path
|
||||||
fill_in "document_verification_document_number", with: "12345678Z"
|
fill_in "document_verification_document_number", with: "12345678Z"
|
||||||
click_button "Check document"
|
click_button "Check document"
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
describe "Localization" do
|
describe "Localization" do
|
||||||
before do
|
|
||||||
login_as_manager
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Wrong locale" do
|
scenario "Wrong locale" do
|
||||||
|
login_as_manager
|
||||||
visit management_root_path(locale: :es)
|
visit management_root_path(locale: :es)
|
||||||
visit management_root_path(locale: :klingon)
|
visit management_root_path(locale: :klingon)
|
||||||
|
|
||||||
@@ -13,7 +10,7 @@ describe "Localization" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Available locales appear in the locale switcher" do
|
scenario "Available locales appear in the locale switcher" do
|
||||||
visit management_root_path
|
login_as_manager
|
||||||
|
|
||||||
within(".locale-form .js-location-changer") do
|
within(".locale-form .js-location-changer") do
|
||||||
expect(page).to have_content "Español"
|
expect(page).to have_content "Español"
|
||||||
@@ -22,13 +19,13 @@ describe "Localization" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "The current locale is selected" do
|
scenario "The current locale is selected" do
|
||||||
visit management_root_path
|
login_as_manager
|
||||||
expect(page).to have_select("locale-switcher", selected: "English")
|
expect(page).to have_select("locale-switcher", selected: "English")
|
||||||
expect(page).to have_text("Management")
|
expect(page).to have_text("Management")
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Changing the locale" do
|
scenario "Changing the locale" do
|
||||||
visit management_root_path
|
login_as_manager
|
||||||
expect(page).to have_content("Language")
|
expect(page).to have_content("Language")
|
||||||
|
|
||||||
select("Español", from: "locale-switcher")
|
select("Español", from: "locale-switcher")
|
||||||
@@ -40,7 +37,7 @@ describe "Localization" do
|
|||||||
scenario "Locale switcher not present if only one locale" do
|
scenario "Locale switcher not present if only one locale" do
|
||||||
allow(I18n).to receive(:available_locales).and_return([:en])
|
allow(I18n).to receive(:available_locales).and_return([:en])
|
||||||
|
|
||||||
visit management_root_path
|
login_as_manager
|
||||||
expect(page).not_to have_content("Language")
|
expect(page).not_to have_content("Language")
|
||||||
expect(page).not_to have_css("div.locale")
|
expect(page).not_to have_css("div.locale")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
describe "Managed User" do
|
describe "Managed User" do
|
||||||
before do
|
|
||||||
login_as_manager
|
|
||||||
end
|
|
||||||
|
|
||||||
context "Currently managed user" do
|
context "Currently managed user" do
|
||||||
scenario "No managed user" do
|
scenario "No managed user" do
|
||||||
|
login_as_manager
|
||||||
visit management_document_verifications_path
|
visit management_document_verifications_path
|
||||||
expect(page).not_to have_css ".account-info"
|
expect(page).not_to have_css ".account-info"
|
||||||
end
|
end
|
||||||
@@ -14,6 +11,7 @@ describe "Managed User" do
|
|||||||
scenario "User is already level three verified" do
|
scenario "User is already level three verified" do
|
||||||
user = create(:user, :level_three)
|
user = create(:user, :level_three)
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
visit management_document_verifications_path
|
visit management_document_verifications_path
|
||||||
fill_in "document_verification_document_number", with: user.document_number
|
fill_in "document_verification_document_number", with: user.document_number
|
||||||
click_button "Check document"
|
click_button "Check document"
|
||||||
@@ -31,6 +29,7 @@ describe "Managed User" do
|
|||||||
scenario "User becomes verified as level three" do
|
scenario "User becomes verified as level three" do
|
||||||
user = create(:user, :level_two)
|
user = create(:user, :level_two)
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
visit management_document_verifications_path
|
visit management_document_verifications_path
|
||||||
fill_in "document_verification_document_number", with: user.document_number
|
fill_in "document_verification_document_number", with: user.document_number
|
||||||
click_button "Check document"
|
click_button "Check document"
|
||||||
@@ -50,10 +49,9 @@ describe "Managed User" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "User becomes verified as level two (pending email confirmation for level three)" do
|
scenario "User becomes verified as level two (pending email confirmation for level three)" do
|
||||||
login_as_manager
|
|
||||||
|
|
||||||
user = create(:user)
|
user = create(:user)
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
visit management_document_verifications_path
|
visit management_document_verifications_path
|
||||||
fill_in "document_verification_document_number", with: "12345678Z"
|
fill_in "document_verification_document_number", with: "12345678Z"
|
||||||
click_button "Check document"
|
click_button "Check document"
|
||||||
@@ -141,6 +139,7 @@ describe "Managed User" do
|
|||||||
scenario "Close the currently managed user session" do
|
scenario "Close the currently managed user session" do
|
||||||
user = create(:user, :level_three)
|
user = create(:user, :level_three)
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
visit management_document_verifications_path
|
visit management_document_verifications_path
|
||||||
fill_in "document_verification_document_number", with: user.document_number
|
fill_in "document_verification_document_number", with: user.document_number
|
||||||
click_button "Check document"
|
click_button "Check document"
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ describe "Proposals" do
|
|||||||
|
|
||||||
before do
|
before do
|
||||||
login_managed_user(user)
|
login_managed_user(user)
|
||||||
login_as_manager
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "Create" do
|
context "Create" do
|
||||||
scenario "Creating proposals on behalf of someone" do
|
scenario "Creating proposals on behalf of someone" do
|
||||||
|
login_as_manager
|
||||||
click_link "Create proposal"
|
click_link "Create proposal"
|
||||||
|
|
||||||
within(".account-info") do
|
within(".account-info") do
|
||||||
@@ -42,6 +42,7 @@ describe "Proposals" do
|
|||||||
scenario "Should not allow unverified users to create proposals" do
|
scenario "Should not allow unverified users to create proposals" do
|
||||||
login_managed_user(create(:user))
|
login_managed_user(create(:user))
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
click_link "Create proposal"
|
click_link "Create proposal"
|
||||||
|
|
||||||
expect(page).to have_content "User is not verified"
|
expect(page).to have_content "User is not verified"
|
||||||
@@ -53,6 +54,7 @@ describe "Proposals" do
|
|||||||
proposal = create(:proposal)
|
proposal = create(:proposal)
|
||||||
|
|
||||||
right_path = management_proposal_path(proposal)
|
right_path = management_proposal_path(proposal)
|
||||||
|
login_as_manager
|
||||||
visit right_path
|
visit right_path
|
||||||
|
|
||||||
expect(page).to have_current_path(right_path)
|
expect(page).to have_current_path(right_path)
|
||||||
@@ -63,6 +65,8 @@ describe "Proposals" do
|
|||||||
|
|
||||||
right_path = management_proposal_path(proposal)
|
right_path = management_proposal_path(proposal)
|
||||||
old_path = "#{management_proposals_path}/#{proposal.id}-something-else"
|
old_path = "#{management_proposals_path}/#{proposal.id}-something-else"
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
visit old_path
|
visit old_path
|
||||||
|
|
||||||
expect(page).not_to have_current_path(old_path)
|
expect(page).not_to have_current_path(old_path)
|
||||||
@@ -72,6 +76,7 @@ describe "Proposals" do
|
|||||||
scenario "Successful proposal" do
|
scenario "Successful proposal" do
|
||||||
proposal = create(:proposal, :successful, title: "Success!")
|
proposal = create(:proposal, :successful, title: "Success!")
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
visit management_proposal_path(proposal)
|
visit management_proposal_path(proposal)
|
||||||
|
|
||||||
expect(page).to have_content("Success!")
|
expect(page).to have_content("Success!")
|
||||||
@@ -82,6 +87,7 @@ describe "Proposals" do
|
|||||||
proposal1 = create(:proposal, title: "Show me what you got")
|
proposal1 = create(:proposal, title: "Show me what you got")
|
||||||
proposal2 = create(:proposal, title: "Get Schwifty")
|
proposal2 = create(:proposal, title: "Get Schwifty")
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
click_link "Support proposals"
|
click_link "Support proposals"
|
||||||
|
|
||||||
fill_in "search", with: "what you got"
|
fill_in "search", with: "what you got"
|
||||||
@@ -102,6 +108,7 @@ describe "Proposals" do
|
|||||||
proposal1 = create(:proposal, title: "Show me what you got")
|
proposal1 = create(:proposal, title: "Show me what you got")
|
||||||
proposal2 = create(:proposal, title: "Get Schwifty")
|
proposal2 = create(:proposal, title: "Get Schwifty")
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
click_link "Support proposals"
|
click_link "Support proposals"
|
||||||
|
|
||||||
expect(page).to have_current_path(management_proposals_path)
|
expect(page).to have_current_path(management_proposals_path)
|
||||||
@@ -126,6 +133,7 @@ describe "Proposals" do
|
|||||||
let!(:proposal) { create(:proposal) }
|
let!(:proposal) { create(:proposal) }
|
||||||
|
|
||||||
scenario "Voting proposals on behalf of someone in index view" do
|
scenario "Voting proposals on behalf of someone in index view" do
|
||||||
|
login_as_manager
|
||||||
click_link "Support proposals"
|
click_link "Support proposals"
|
||||||
|
|
||||||
within(".proposals-list") do
|
within(".proposals-list") do
|
||||||
@@ -138,6 +146,7 @@ describe "Proposals" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Voting proposals on behalf of someone in show view" do
|
scenario "Voting proposals on behalf of someone in show view" do
|
||||||
|
login_as_manager
|
||||||
click_link "Support proposals"
|
click_link "Support proposals"
|
||||||
|
|
||||||
within(".proposals-list") { click_link proposal.title }
|
within(".proposals-list") { click_link proposal.title }
|
||||||
@@ -153,6 +162,7 @@ describe "Proposals" do
|
|||||||
scenario "Should not allow unverified users to vote proposals" do
|
scenario "Should not allow unverified users to vote proposals" do
|
||||||
login_managed_user(create(:user))
|
login_managed_user(create(:user))
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
click_link "Support proposals"
|
click_link "Support proposals"
|
||||||
|
|
||||||
expect(page).to have_content "User is not verified"
|
expect(page).to have_content "User is not verified"
|
||||||
@@ -163,6 +173,7 @@ describe "Proposals" do
|
|||||||
scenario "Printing proposals" do
|
scenario "Printing proposals" do
|
||||||
6.times { create(:proposal) }
|
6.times { create(:proposal) }
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
click_link "Print proposals"
|
click_link "Print proposals"
|
||||||
|
|
||||||
expect(page).to have_css(".proposal", count: 5)
|
expect(page).to have_css(".proposal", count: 5)
|
||||||
@@ -177,6 +188,7 @@ describe "Proposals" do
|
|||||||
medium_proposal = create(:proposal, title: "Medium proposal")
|
medium_proposal = create(:proposal, title: "Medium proposal")
|
||||||
medium_proposal.update_column(:confidence_score, 5)
|
medium_proposal.update_column(:confidence_score, 5)
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
click_link "Print proposals"
|
click_link "Print proposals"
|
||||||
|
|
||||||
expect(page).to have_selector(".js-order-selector[data-order='confidence_score']")
|
expect(page).to have_selector(".js-order-selector[data-order='confidence_score']")
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
describe "Users" do
|
describe "Users" do
|
||||||
before do
|
|
||||||
login_as_manager
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Create a level 3 user with email from scratch" do
|
scenario "Create a level 3 user with email from scratch" do
|
||||||
|
login_as_manager
|
||||||
visit management_document_verifications_path
|
visit management_document_verifications_path
|
||||||
fill_in "document_verification_document_number", with: "12345678Z"
|
fill_in "document_verification_document_number", with: "12345678Z"
|
||||||
click_button "Check document"
|
click_button "Check document"
|
||||||
@@ -46,6 +43,7 @@ describe "Users" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Create a level 3 user without email from scratch" do
|
scenario "Create a level 3 user without email from scratch" do
|
||||||
|
login_as_manager
|
||||||
visit management_document_verifications_path
|
visit management_document_verifications_path
|
||||||
fill_in "document_verification_document_number", with: "12345678Z"
|
fill_in "document_verification_document_number", with: "12345678Z"
|
||||||
click_button "Check document"
|
click_button "Check document"
|
||||||
@@ -74,6 +72,7 @@ describe "Users" do
|
|||||||
scenario "Delete a level 2 user account from document verification page" do
|
scenario "Delete a level 2 user account from document verification page" do
|
||||||
level_2_user = create(:user, :level_two, document_number: "12345678Z")
|
level_2_user = create(:user, :level_two, document_number: "12345678Z")
|
||||||
|
|
||||||
|
login_as_manager
|
||||||
visit management_document_verifications_path
|
visit management_document_verifications_path
|
||||||
fill_in "document_verification_document_number", with: "12345678Z"
|
fill_in "document_verification_document_number", with: "12345678Z"
|
||||||
click_button "Check document"
|
click_button "Check document"
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
describe "User invites" do
|
describe "User invites" do
|
||||||
before do
|
|
||||||
login_as_manager
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Send invitations" do
|
scenario "Send invitations" do
|
||||||
|
login_as_manager
|
||||||
visit new_management_user_invite_path
|
visit new_management_user_invite_path
|
||||||
|
|
||||||
fill_in "emails", with: "john@example.com, ana@example.com, isable@example.com"
|
fill_in "emails", with: "john@example.com, ana@example.com, isable@example.com"
|
||||||
|
|||||||
Reference in New Issue
Block a user