devise_masquerade 1.0.0 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +1 -0
- data/.github/workflows/brakeman-analysis.yml +44 -0
- data/.github/workflows/rubocop-analysis.yml +39 -0
- data/.ruby-version +1 -1
- data/.travis.yml +1 -0
- data/Gemfile +4 -2
- data/Gemfile.lock +31 -18
- data/README.md +21 -1
- data/app/controllers/devise/masquerades_controller.rb +66 -24
- data/devise_masquerade.gemspec +1 -1
- data/features/back.feature +0 -1
- data/features/multiple_masquerading_models.feature +17 -0
- data/features/step_definitions/auth_steps.rb +1 -0
- data/features/step_definitions/back_steps.rb +18 -3
- data/features/step_definitions/url_helpers_steps.rb +11 -0
- data/features/url_helpers.feature +14 -0
- data/lib/devise_masquerade.rb +5 -5
- data/lib/devise_masquerade/controllers/helpers.rb +27 -6
- data/lib/devise_masquerade/controllers/url_helpers.rb +14 -2
- data/lib/devise_masquerade/models/masqueradable.rb +2 -27
- data/lib/devise_masquerade/rails.rb +5 -7
- data/lib/devise_masquerade/routes.rb +3 -2
- data/lib/devise_masquerade/version.rb +1 -1
- data/spec/controllers/admin/dashboard_controller_spec.rb +3 -4
- data/spec/controllers/dashboard_controller_spec.rb +3 -5
- data/spec/controllers/devise/masquerades_controller_spec.rb +60 -39
- data/spec/controllers/masquerades_tests_controller_spec.rb +41 -0
- data/spec/dummy/app/controllers/admin/dashboard_controller.rb +0 -1
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/controllers/dashboard_controller.rb +4 -1
- data/spec/dummy/app/controllers/masquerades_tests_controller.rb +7 -0
- data/spec/dummy/app/controllers/students_controller.rb +8 -0
- data/spec/dummy/app/models/student.rb +3 -0
- data/spec/dummy/app/views/admin/dashboard/index.html.erb +0 -2
- data/spec/dummy/app/views/dashboard/extra_params.html.erb +7 -0
- data/spec/dummy/app/views/dashboard/index.html.erb +0 -2
- data/spec/dummy/app/views/layouts/application.html.erb +8 -2
- data/spec/dummy/app/views/students/_student.html.erb +6 -0
- data/spec/dummy/app/views/students/index.html.erb +1 -0
- data/spec/dummy/app/views/users/_user.html.erb +1 -1
- data/spec/dummy/config/routes.rb +9 -5
- data/spec/dummy/db/migrate/20191022100000_create_students.rb +14 -0
- data/spec/dummy/db/schema.rb +10 -1
- data/spec/models/user_spec.rb +3 -30
- data/spec/support/factories.rb +8 -4
- metadata +34 -13
- data/spec/controllers/masquerades_controller_spec.rb +0 -42
- data/spec/dummy/app/controllers/masquerades_controller.rb +0 -5
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe MasqueradesController, type: :controller do
|
4
|
-
before { @request.env['devise.mapping'] = Devise.mappings[:user] }
|
5
|
-
|
6
|
-
context 'no access for masquerade' do
|
7
|
-
before do
|
8
|
-
session.clear
|
9
|
-
allow_any_instance_of(MasqueradesController).to receive(:masquerade_authorized?) { false }
|
10
|
-
end
|
11
|
-
|
12
|
-
before { logged_in }
|
13
|
-
|
14
|
-
let(:mask) { create(:user) }
|
15
|
-
|
16
|
-
before { get :show, params: { :id => mask.to_param } }
|
17
|
-
|
18
|
-
it { expect(response.status).to eq(403) }
|
19
|
-
it { expect(session.keys).not_to include('devise_masquerade_user') }
|
20
|
-
it { expect(session["warden.user.user.key"].first.first).not_to eq(mask.id) }
|
21
|
-
end
|
22
|
-
|
23
|
-
context 'access for masquerade' do
|
24
|
-
before do
|
25
|
-
session.clear
|
26
|
-
allow_any_instance_of(MasqueradesController).to receive(:masquerade_authorized?) { true }
|
27
|
-
end
|
28
|
-
|
29
|
-
before { logged_in }
|
30
|
-
|
31
|
-
let(:mask) { create(:user) }
|
32
|
-
|
33
|
-
before do
|
34
|
-
expect(SecureRandom).to receive(:urlsafe_base64) { "secure_key" }
|
35
|
-
get :show, params: { id: mask.to_param }
|
36
|
-
end
|
37
|
-
|
38
|
-
it { expect(response.status).to eq(302) }
|
39
|
-
it { expect(session.keys).to include('devise_masquerade_user') }
|
40
|
-
it { expect(session["warden.user.user.key"].first.first).to eq(mask.id) }
|
41
|
-
end
|
42
|
-
end
|