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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -0
  3. data/.github/workflows/brakeman-analysis.yml +44 -0
  4. data/.github/workflows/rubocop-analysis.yml +39 -0
  5. data/.ruby-version +1 -1
  6. data/.travis.yml +1 -0
  7. data/Gemfile +4 -2
  8. data/Gemfile.lock +31 -18
  9. data/README.md +21 -1
  10. data/app/controllers/devise/masquerades_controller.rb +66 -24
  11. data/devise_masquerade.gemspec +1 -1
  12. data/features/back.feature +0 -1
  13. data/features/multiple_masquerading_models.feature +17 -0
  14. data/features/step_definitions/auth_steps.rb +1 -0
  15. data/features/step_definitions/back_steps.rb +18 -3
  16. data/features/step_definitions/url_helpers_steps.rb +11 -0
  17. data/features/url_helpers.feature +14 -0
  18. data/lib/devise_masquerade.rb +5 -5
  19. data/lib/devise_masquerade/controllers/helpers.rb +27 -6
  20. data/lib/devise_masquerade/controllers/url_helpers.rb +14 -2
  21. data/lib/devise_masquerade/models/masqueradable.rb +2 -27
  22. data/lib/devise_masquerade/rails.rb +5 -7
  23. data/lib/devise_masquerade/routes.rb +3 -2
  24. data/lib/devise_masquerade/version.rb +1 -1
  25. data/spec/controllers/admin/dashboard_controller_spec.rb +3 -4
  26. data/spec/controllers/dashboard_controller_spec.rb +3 -5
  27. data/spec/controllers/devise/masquerades_controller_spec.rb +60 -39
  28. data/spec/controllers/masquerades_tests_controller_spec.rb +41 -0
  29. data/spec/dummy/app/controllers/admin/dashboard_controller.rb +0 -1
  30. data/spec/dummy/app/controllers/application_controller.rb +2 -0
  31. data/spec/dummy/app/controllers/dashboard_controller.rb +4 -1
  32. data/spec/dummy/app/controllers/masquerades_tests_controller.rb +7 -0
  33. data/spec/dummy/app/controllers/students_controller.rb +8 -0
  34. data/spec/dummy/app/models/student.rb +3 -0
  35. data/spec/dummy/app/views/admin/dashboard/index.html.erb +0 -2
  36. data/spec/dummy/app/views/dashboard/extra_params.html.erb +7 -0
  37. data/spec/dummy/app/views/dashboard/index.html.erb +0 -2
  38. data/spec/dummy/app/views/layouts/application.html.erb +8 -2
  39. data/spec/dummy/app/views/students/_student.html.erb +6 -0
  40. data/spec/dummy/app/views/students/index.html.erb +1 -0
  41. data/spec/dummy/app/views/users/_user.html.erb +1 -1
  42. data/spec/dummy/config/routes.rb +9 -5
  43. data/spec/dummy/db/migrate/20191022100000_create_students.rb +14 -0
  44. data/spec/dummy/db/schema.rb +10 -1
  45. data/spec/models/user_spec.rb +3 -30
  46. data/spec/support/factories.rb +8 -4
  47. metadata +34 -13
  48. data/spec/controllers/masquerades_controller_spec.rb +0 -42
  49. 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
@@ -1,5 +0,0 @@
1
- class MasqueradesController < Devise::MasqueradesController
2
- def show
3
- super
4
- end
5
- end