add specs
This commit is contained in:
@@ -31,7 +31,7 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
|
||||
def redirect_locked_accounts
|
||||
if Current.user && Current.account.locked?
|
||||
if Current.user && !Current.user.admin? && Current.account.locked?
|
||||
redirect_to locked_account_path
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,6 +30,24 @@ feature "Admin managing accounts" do
|
||||
expect(page).to have_content "Created at less than a minute ago"
|
||||
end
|
||||
|
||||
scenario "locks and unlocks account" do
|
||||
sign_in current_user
|
||||
visit admin_signed_in_root_path
|
||||
expect(Account.last.locked?).to eq false
|
||||
|
||||
click_button "Manage"
|
||||
expect(page).not_to have_content "Unlock Account"
|
||||
click_link "Lock Account"
|
||||
|
||||
expect(Account.last.locked?).to eq true
|
||||
|
||||
click_button "Manage"
|
||||
expect(page).not_to have_content "Lock Account"
|
||||
click_link "Unlock Account"
|
||||
|
||||
expect(Account.last.locked?).to eq false
|
||||
end
|
||||
|
||||
scenario "sees videos for an account in the system" do
|
||||
visit_account_overview_page
|
||||
|
||||
|
||||
34
spec/features/user_managing_locked_account_spec.rb
Normal file
34
spec/features/user_managing_locked_account_spec.rb
Normal file
@@ -0,0 +1,34 @@
|
||||
require "rails_helper"
|
||||
|
||||
feature "User managing locked account" do
|
||||
let(:user) { create(:user, :account_manager) }
|
||||
let(:project) { create(:project) }
|
||||
|
||||
before do
|
||||
sign_in(user)
|
||||
user.accounts.first.update(locked: true)
|
||||
end
|
||||
|
||||
scenario "user is redirected to custom landing page when opens projects index page" do
|
||||
paths = [
|
||||
projects_path,
|
||||
project_path(project),
|
||||
project_task_requests_path(project),
|
||||
project_contract_templates_path(project),
|
||||
project_broadcasts_path(project),
|
||||
project_videos_path(project),
|
||||
]
|
||||
|
||||
paths.each do |path|
|
||||
visit path
|
||||
|
||||
expect(page).to have_content locked_account_warning
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def locked_account_warning
|
||||
t 'locked_accounts.index.account_locked_message'
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user