alchemy-devise 3.6.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +32 -8
- data/Rakefile +8 -2
- data/app/models/alchemy/user.rb +2 -13
- data/db/migrate/20131015124700_create_alchemy_users.rb +1 -1
- data/db/migrate/20131225232042_add_alchemy_roles_to_alchemy_users.rb +1 -1
- data/db/migrate/20141209144532_add_indexes_to_alchemy_users.rb +1 -1
- data/lib/alchemy/devise.rb +35 -0
- data/lib/alchemy/devise/test_support/factories.rb +1 -1
- data/lib/alchemy/devise/version.rb +1 -1
- data/spec/controllers/admin/users_controller_spec.rb +29 -21
- data/spec/controllers/user_sessions_controller_spec.rb +21 -19
- data/spec/dummy/app/views/layouts/application.html.erb +2 -2
- data/spec/dummy/bin/rails +1 -5
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/bin/rspec +0 -4
- data/spec/dummy/bin/setup +34 -0
- data/spec/dummy/bin/update +29 -0
- data/spec/dummy/config/application.rb +4 -14
- data/spec/dummy/config/boot.rb +3 -3
- data/spec/dummy/config/environment.rb +2 -2
- data/spec/dummy/config/environments/development.rb +24 -11
- data/spec/dummy/config/environments/production.rb +24 -17
- data/spec/dummy/config/environments/test.rb +6 -6
- data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +2 -0
- data/spec/dummy/config/initializers/new_framework_defaults.rb +25 -0
- data/spec/dummy/config/initializers/session_store.rb +1 -1
- data/spec/dummy/config/initializers/wrap_parameters.rb +2 -2
- data/spec/dummy/config/puma.rb +47 -0
- data/spec/dummy/config/routes.rb +1 -1
- data/spec/dummy/config/secrets.yml +3 -3
- data/spec/dummy/db/migrate/20131018201539_alchemy_two_point_six.alchemy.rb +1 -1
- data/spec/dummy/db/migrate/20131018201540_remove_do_not_index_from_alchemy_essence_texts.alchemy.rb +1 -1
- data/spec/dummy/db/migrate/20131018201541_remove_do_not_index_from_alchemy_essence_richtexts.alchemy.rb +1 -1
- data/spec/dummy/db/migrate/20141119205155_add_published_at_to_alchemy_pages.alchemy.rb +1 -1
- data/spec/dummy/db/migrate/20141119205156_add_missing_unique_indices_to_tags_and_taggings.alchemy.rb +1 -1
- data/spec/dummy/db/migrate/20141119205157_add_taggings_counter_cache_to_tags.alchemy.rb +2 -2
- data/spec/dummy/db/migrate/20141119205158_add_missing_taggable_index.alchemy.rb +1 -1
- data/spec/dummy/db/migrate/20160322214808_add_parent_element_id_to_alchemy_elements.alchemy.rb +1 -1
- data/spec/dummy/db/migrate/20160322214809_add_link_text_to_alchemy_essence_files.alchemy.rb +1 -1
- data/spec/dummy/db/migrate/20160518190421_add_locale_to_alchemy_languages.alchemy.rb +1 -1
- data/spec/dummy/db/migrate/20160518190425_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb +1 -1
- data/spec/dummy/db/migrate/20160518190426_add_missing_unique_indices.acts_as_taggable_on_engine.rb +1 -1
- data/spec/dummy/db/migrate/20160518190427_change_collation_for_tag_names.acts_as_taggable_on_engine.rb +1 -1
- data/spec/dummy/db/migrate/20160614164602_add_timebased_publishing_columns_to_pages.alchemy.rb +1 -1
- data/spec/dummy/db/migrate/20160614164603_add_image_file_format_to_alchemy_pictures.alchemy.rb +1 -1
- data/spec/dummy/db/migrate/20160627081901_change_alchemy_pages_locked_to_locked_at.alchemy.rb +1 -1
- data/spec/dummy/db/migrate/20161106124022_add_index_to_alchemy_pages_rgt.alchemy.rb +1 -1
- data/spec/dummy/db/migrate/20161106124023_add_foreign_key_indices_and_null_constraints.alchemy.rb +1 -1
- data/spec/dummy/db/migrate/20161106124024_add_foreign_keys.alchemy.rb +1 -1
- data/spec/dummy/db/migrate/20161106124026_add_missing_indexes.acts_as_taggable_on_engine.rb +1 -1
- data/spec/dummy/db/schema.rb +233 -250
- data/spec/requests/admin/users_controller_request_spec.rb +2 -2
- data/spec/spec_helper.rb +6 -2
- metadata +23 -18
- data/spec/dummy/bin/spring +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6503112660ffd7d7987f2a803c79ada797984a0c
|
4
|
+
data.tar.gz: f89664312b98e5e867d62c75be62a81a04618c9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbbc12bd8232f6a085e53315c8090c0027a294e7f16642055ab1f0c6a42c4393f39ec3c69d83fdb6b180e19e1cec02d5257ec9d14c6a8b99100edd8a4235b2a2
|
7
|
+
data.tar.gz: fd765d3f74e772b8cfbe222fc3875d53dc65220d4db1baed2c506167a06c8c1820d5419d966d0cca2bf6947072be9062b507f8b59c88bd8ceb0ee8e24740512e
|
data/README.md
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
## Devise based authentication for
|
1
|
+
## Devise based authentication for AlchemyCMS 4.0
|
2
2
|
|
3
|
-
[![Build Status](https://secure.travis-ci.org/AlchemyCMS/alchemy-devise.svg?branch=
|
3
|
+
[![Build Status](https://secure.travis-ci.org/AlchemyCMS/alchemy-devise.svg?branch=4.0-stable)](http://travis-ci.org/AlchemyCMS/alchemy-devise)
|
4
4
|
|
5
|
-
[![Gem Version](https://badge.fury.io/rb/alchemy-devise.svg)](http://badge.fury.io/rb/alchemy-devise) [![Test Coverage](https://codeclimate.com/github/AlchemyCMS/alchemy-devise/badges/coverage.svg)](https://codeclimate.com/github/AlchemyCMS/alchemy-devise/coverage) [![Code Climate](https://codeclimate.com/github/AlchemyCMS/alchemy-devise/badges/gpa.svg)](https://codeclimate.com/github/AlchemyCMS/alchemy-devise) [![security](https://hakiri.io/github/AlchemyCMS/alchemy-devise/
|
6
|
-
|
7
|
-
**CAUTION: This master branch is a development branch that can contain bugs. For productive environments you should use the [current Ruby gem version](https://rubygems.org/gems/alchemy-devise/versions/3.5.0), or the [latest stable branch (3.5-stable)](https://github.com/AlchemyCMS/alchemy-devise/tree/3.5-stable).**
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/alchemy-devise.svg)](http://badge.fury.io/rb/alchemy-devise) [![Test Coverage](https://codeclimate.com/github/AlchemyCMS/alchemy-devise/badges/coverage.svg)](https://codeclimate.com/github/AlchemyCMS/alchemy-devise/coverage) [![Code Climate](https://codeclimate.com/github/AlchemyCMS/alchemy-devise/badges/gpa.svg)](https://codeclimate.com/github/AlchemyCMS/alchemy-devise) [![security](https://hakiri.io/github/AlchemyCMS/alchemy-devise/4.0-stable.svg)](https://hakiri.io/github/AlchemyCMS/alchemy-devise/4.0-stable) [![Dependency Status](https://gemnasium.com/AlchemyCMS/alchemy-devise.svg)](https://gemnasium.com/AlchemyCMS/alchemy-devise)
|
8
6
|
|
9
7
|
AlchemyCMS has no authentication in its core. So it is possibly to bring your own authentication and use it to authorize users in AlchemyCMS. If you don't have your own authentication, you can use this gem.
|
10
8
|
|
@@ -14,11 +12,9 @@ Just put the gem into your projects `Gemfile`.
|
|
14
12
|
|
15
13
|
```ruby
|
16
14
|
# Gemfile
|
17
|
-
gem 'alchemy-devise', github: 'AlchemyCMS/alchemy-devise', branch: '
|
15
|
+
gem 'alchemy-devise', github: 'AlchemyCMS/alchemy-devise', branch: '4.0-stable'
|
18
16
|
```
|
19
17
|
|
20
|
-
**NOTE:** You normally want to use a stable branch, like `3.5-stable`.
|
21
|
-
|
22
18
|
and run `bundle install`.
|
23
19
|
|
24
20
|
Then run the installer:
|
@@ -36,6 +32,34 @@ $ bundle update alchemy-devise
|
|
36
32
|
$ bin/rails g alchemy:devise:install
|
37
33
|
```
|
38
34
|
|
35
|
+
## Devise modules
|
36
|
+
|
37
|
+
Default Devise modules included in `Alchemy::User` model
|
38
|
+
|
39
|
+
- `:database_authenticatable`
|
40
|
+
- `:trackable`
|
41
|
+
- `:validatable`
|
42
|
+
- `:timeoutable`
|
43
|
+
- `:recoverable`
|
44
|
+
|
45
|
+
If you want to add additional modules into the Alchemy user class append them to `Alchemy.devise_modules` in an initializer in your app.
|
46
|
+
|
47
|
+
### Register additional modules example
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
# config/initializers/alchemy.rb
|
51
|
+
Alchemy.devise_modules << :registerable
|
52
|
+
```
|
53
|
+
|
54
|
+
### Using old encryption
|
55
|
+
|
56
|
+
If your app uses an old encryption that needs the +devise-encryptable+ gem you also need to load the devise module.
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
# config/initializers/alchemy.rb
|
60
|
+
Alchemy.devise_modules << :encryptable
|
61
|
+
```
|
62
|
+
|
39
63
|
## Testing
|
40
64
|
|
41
65
|
If you want to contribute (and you should ^_^), you need to run the tests locally on your machine.
|
data/Rakefile
CHANGED
@@ -28,10 +28,16 @@ Bundler::GemHelper.install_tasks
|
|
28
28
|
|
29
29
|
namespace :alchemy do
|
30
30
|
namespace :spec do
|
31
|
-
|
32
31
|
desc "Prepares database for testing Alchemy"
|
33
32
|
task :prepare do
|
34
|
-
system
|
33
|
+
system <<-BASH
|
34
|
+
cd spec/dummy
|
35
|
+
export RAILS_ENV=test
|
36
|
+
bin/rake db:environment:set
|
37
|
+
bin/rake db:migrate:reset
|
38
|
+
bin/rails g alchemy:devise:install --force
|
39
|
+
cd -
|
40
|
+
BASH
|
35
41
|
end
|
36
42
|
end
|
37
43
|
end
|
data/app/models/alchemy/user.rb
CHANGED
@@ -16,19 +16,8 @@ module Alchemy
|
|
16
16
|
:send_credentials,
|
17
17
|
:tag_list
|
18
18
|
]
|
19
|
-
|
20
|
-
|
21
|
-
:trackable,
|
22
|
-
:validatable,
|
23
|
-
:timeoutable,
|
24
|
-
:recoverable
|
25
|
-
]
|
26
|
-
# If the app uses an old encryption it uses the devise-encryptable gem
|
27
|
-
# therefore we have to load the devise module
|
28
|
-
if (::Devise::Models::Encryptable rescue false)
|
29
|
-
DEVISE_MODULES.push(:encryptable)
|
30
|
-
end
|
31
|
-
devise *DEVISE_MODULES
|
19
|
+
|
20
|
+
devise *Alchemy.devise_modules
|
32
21
|
|
33
22
|
acts_as_taggable
|
34
23
|
acts_as_tagger
|
data/lib/alchemy/devise.rb
CHANGED
@@ -1,6 +1,41 @@
|
|
1
1
|
require "alchemy/devise/engine"
|
2
2
|
|
3
3
|
module Alchemy
|
4
|
+
# Devise modules included in +Alchemy::User+ model
|
5
|
+
#
|
6
|
+
# === Default modules
|
7
|
+
#
|
8
|
+
# [
|
9
|
+
#. :database_authenticatable,
|
10
|
+
# :trackable,
|
11
|
+
# :validatable,
|
12
|
+
# :timeoutable,
|
13
|
+
# :recoverable
|
14
|
+
#. ]
|
15
|
+
#
|
16
|
+
# If you want to add additional modules into the Alchemy user class append
|
17
|
+
# them to this collection in an initializer in your app.
|
18
|
+
#
|
19
|
+
# === Example
|
20
|
+
#
|
21
|
+
# # config/initializers/alchemy.rb
|
22
|
+
# Alchemy.devise_modules << :registerable
|
23
|
+
#
|
24
|
+
# If your app uses an old encryption that needs the +devise-encryptable+ gem
|
25
|
+
# you also need to load the devise module.
|
26
|
+
#
|
27
|
+
# Alchemy.devise_modules << :encryptable
|
28
|
+
#
|
29
|
+
def self.devise_modules
|
30
|
+
@devise_modules ||= [
|
31
|
+
:database_authenticatable,
|
32
|
+
:trackable,
|
33
|
+
:validatable,
|
34
|
+
:timeoutable,
|
35
|
+
:recoverable
|
36
|
+
]
|
37
|
+
end
|
38
|
+
|
4
39
|
module Devise
|
5
40
|
end
|
6
41
|
end
|
@@ -2,6 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Alchemy
|
4
4
|
describe Admin::UsersController do
|
5
|
+
routes { Alchemy::Engine.routes }
|
6
|
+
|
5
7
|
let(:admin) { build_stubbed(:alchemy_admin_user) }
|
6
8
|
let(:user) { build_stubbed(:alchemy_user) }
|
7
9
|
|
@@ -16,21 +18,21 @@ module Alchemy
|
|
16
18
|
|
17
19
|
context 'with matching search query' do
|
18
20
|
it "lists all matching users" do
|
19
|
-
|
21
|
+
get :index, params: {q: { email_cont: user.email }}
|
20
22
|
expect(assigns(:users)).to include(user)
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
24
26
|
context 'with non-matching search query' do
|
25
27
|
it "lists all matching users" do
|
26
|
-
|
28
|
+
get :index, params: {q: { email_cont: "Tarzan" }}
|
27
29
|
expect(assigns(:users)).not_to include(user)
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
31
33
|
context 'without search query' do
|
32
34
|
it "lists all users" do
|
33
|
-
|
35
|
+
get :index
|
34
36
|
expect(assigns(:users)).to include(user)
|
35
37
|
end
|
36
38
|
end
|
@@ -41,7 +43,7 @@ module Alchemy
|
|
41
43
|
before { allow(User).to receive_messages(count: 1) }
|
42
44
|
|
43
45
|
it "redirects to admin dashboard" do
|
44
|
-
|
46
|
+
get :signup
|
45
47
|
expect(response).to redirect_to(admin_dashboard_path)
|
46
48
|
end
|
47
49
|
end
|
@@ -50,8 +52,12 @@ module Alchemy
|
|
50
52
|
describe '#create' do
|
51
53
|
before { ActionMailer::Base.deliveries.clear }
|
52
54
|
|
55
|
+
around do |example|
|
56
|
+
perform_enqueued_jobs { example.run }
|
57
|
+
end
|
58
|
+
|
53
59
|
it "creates an user record" do
|
54
|
-
|
60
|
+
post :create, params: {user: attributes_for(:alchemy_user)}
|
55
61
|
expect(Alchemy::User.count).to eq(1)
|
56
62
|
end
|
57
63
|
|
@@ -59,27 +65,27 @@ module Alchemy
|
|
59
65
|
before { allow(User).to receive(:count).and_return(0) }
|
60
66
|
|
61
67
|
it "sets the user role to admin." do
|
62
|
-
|
68
|
+
post :create, params: {user: attributes_for(:alchemy_admin_user)}
|
63
69
|
expect(assigns(:user).alchemy_roles).to include("admin")
|
64
70
|
end
|
65
71
|
|
66
72
|
context "with valid params" do
|
67
73
|
it "signs the user in." do
|
68
74
|
expect(controller).to receive(:sign_in)
|
69
|
-
|
75
|
+
post :create, params: {user: attributes_for(:alchemy_admin_user)}
|
70
76
|
end
|
71
77
|
end
|
72
78
|
end
|
73
79
|
|
74
80
|
context "with send_credentials set to '1'" do
|
75
81
|
it "should send an email notification" do
|
76
|
-
|
82
|
+
post :create, params: {user: attributes_for(:alchemy_user).merge(send_credentials: '1')}
|
77
83
|
expect(ActionMailer::Base.deliveries).not_to be_empty
|
78
84
|
end
|
79
85
|
|
80
86
|
context 'with invalid user' do
|
81
87
|
it "does not send an email notification" do
|
82
|
-
|
88
|
+
post :create, params: {user: {send_credentials: '1', email: ''}}
|
83
89
|
expect(ActionMailer::Base.deliveries).to be_empty
|
84
90
|
end
|
85
91
|
end
|
@@ -87,22 +93,24 @@ module Alchemy
|
|
87
93
|
|
88
94
|
context "with send_credentials set to true" do
|
89
95
|
it "should not send an email notification" do
|
90
|
-
|
96
|
+
post :create, params: {user: attributes_for(:alchemy_user).merge(send_credentials: true)}
|
91
97
|
expect(ActionMailer::Base.deliveries).to be_empty
|
92
98
|
end
|
93
99
|
end
|
94
100
|
|
95
101
|
context "with send_credentials left blank" do
|
96
102
|
it "should not send an email notification" do
|
97
|
-
|
103
|
+
post :create, params: {user: attributes_for(:alchemy_user)}
|
98
104
|
expect(ActionMailer::Base.deliveries).to be_empty
|
99
105
|
end
|
100
106
|
end
|
101
107
|
end
|
102
108
|
|
103
109
|
describe '#update' do
|
104
|
-
before
|
105
|
-
|
110
|
+
before { ActionMailer::Base.deliveries.clear }
|
111
|
+
|
112
|
+
around do |example|
|
113
|
+
perform_enqueued_jobs { example.run }
|
106
114
|
end
|
107
115
|
|
108
116
|
context "with empty password passed" do
|
@@ -116,7 +124,7 @@ module Alchemy
|
|
116
124
|
.to receive(:update_without_password)
|
117
125
|
.with(params_hash).and_return(true)
|
118
126
|
|
119
|
-
|
127
|
+
post :update, params: {id: user.id, user: params_hash, format: :js}
|
120
128
|
end
|
121
129
|
end
|
122
130
|
|
@@ -129,7 +137,7 @@ module Alchemy
|
|
129
137
|
}
|
130
138
|
expect(user).to receive(:update).with(params_hash)
|
131
139
|
|
132
|
-
|
140
|
+
post :update, params: {id: user.id, user: params_hash, format: :js}
|
133
141
|
end
|
134
142
|
end
|
135
143
|
|
@@ -137,13 +145,13 @@ module Alchemy
|
|
137
145
|
let(:user) { create(:alchemy_admin_user) }
|
138
146
|
|
139
147
|
it "should send an email notification" do
|
140
|
-
|
148
|
+
post :update, params: {id: user.id, user: {send_credentials: '1'}}
|
141
149
|
expect(ActionMailer::Base.deliveries).to_not be_empty
|
142
150
|
end
|
143
151
|
|
144
152
|
context 'with invalid user' do
|
145
153
|
it "does not send an email notification" do
|
146
|
-
|
154
|
+
post :update, params: {id: user.id, user: {send_credentials: '1', email: ''}}
|
147
155
|
expect(ActionMailer::Base.deliveries).to be_empty
|
148
156
|
end
|
149
157
|
end
|
@@ -153,7 +161,7 @@ module Alchemy
|
|
153
161
|
let(:user) { create(:alchemy_admin_user) }
|
154
162
|
|
155
163
|
it "should not send an email notification" do
|
156
|
-
|
164
|
+
post :update, params: {id: user.id, user: {email: user.email}}
|
157
165
|
expect(ActionMailer::Base.deliveries).to be_empty
|
158
166
|
end
|
159
167
|
end
|
@@ -170,7 +178,7 @@ module Alchemy
|
|
170
178
|
expect(user)
|
171
179
|
.to receive(:update_without_password)
|
172
180
|
.with({'alchemy_roles' => ['Administrator']})
|
173
|
-
|
181
|
+
post :update, params: {id: user.id, user: {alchemy_roles: ['Administrator']}, format: :js}
|
174
182
|
end
|
175
183
|
end
|
176
184
|
|
@@ -184,7 +192,7 @@ module Alchemy
|
|
184
192
|
|
185
193
|
it "updates user without role" do
|
186
194
|
expect(user).to receive(:update_without_password).with({})
|
187
|
-
|
195
|
+
post :update, params: {id: user.id, user: {alchemy_roles: ['Administrator']}, format: :js}
|
188
196
|
end
|
189
197
|
end
|
190
198
|
end
|
@@ -192,7 +200,7 @@ module Alchemy
|
|
192
200
|
describe '#destroy' do
|
193
201
|
it "redirects to users list" do
|
194
202
|
expect(user).to receive(:destroy).and_return(true)
|
195
|
-
|
203
|
+
delete :destroy, params: {id: user.id}
|
196
204
|
expect(response).to redirect_to(admin_users_path)
|
197
205
|
end
|
198
206
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Alchemy::UserSessionsController do
|
4
|
+
routes { Alchemy::Engine.routes }
|
5
|
+
|
4
6
|
before do
|
5
7
|
@request.env["devise.mapping"] = Devise.mappings[:user]
|
6
8
|
end
|
@@ -8,7 +10,7 @@ describe Alchemy::UserSessionsController do
|
|
8
10
|
context 'without users present' do
|
9
11
|
describe '#new' do
|
10
12
|
it "redirects to signup form" do
|
11
|
-
|
13
|
+
get :new
|
12
14
|
is_expected.to redirect_to(admin_signup_path)
|
13
15
|
end
|
14
16
|
|
@@ -18,7 +20,7 @@ describe Alchemy::UserSessionsController do
|
|
18
20
|
end
|
19
21
|
|
20
22
|
it 'redirects to https' do
|
21
|
-
|
23
|
+
get :new
|
22
24
|
is_expected.to redirect_to(
|
23
25
|
login_url(protocol: 'https', host: "test.host")
|
24
26
|
)
|
@@ -39,7 +41,7 @@ describe Alchemy::UserSessionsController do
|
|
39
41
|
|
40
42
|
context 'without redirect path in session' do
|
41
43
|
it "redirects to dashboard" do
|
42
|
-
|
44
|
+
post :create, params: {user: user_params}
|
43
45
|
expect(response).to redirect_to(admin_dashboard_path)
|
44
46
|
end
|
45
47
|
end
|
@@ -47,19 +49,19 @@ describe Alchemy::UserSessionsController do
|
|
47
49
|
context 'with redirect path in session' do
|
48
50
|
it "redirects to these params" do
|
49
51
|
session[:redirect_path] = admin_users_path
|
50
|
-
|
52
|
+
post :create, params: {user: user_params}
|
51
53
|
expect(response).to redirect_to(admin_users_path)
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
55
57
|
it "stores users screen size" do
|
56
|
-
|
58
|
+
post :create, params: {user: user_params, user_screensize: screen_size}
|
57
59
|
expect(session[:screen_size]).to eq(screen_size)
|
58
60
|
end
|
59
61
|
|
60
62
|
context 'without valid params' do
|
61
63
|
it "renders login form" do
|
62
|
-
|
64
|
+
post :create, params: {user: {login: ''}}
|
63
65
|
is_expected.to render_template(:new)
|
64
66
|
end
|
65
67
|
end
|
@@ -77,44 +79,44 @@ describe Alchemy::UserSessionsController do
|
|
77
79
|
|
78
80
|
it "should unlock all pages" do
|
79
81
|
expect(user).to receive(:unlock_pages!)
|
80
|
-
|
82
|
+
delete :destroy
|
81
83
|
end
|
82
84
|
|
83
85
|
context 'comming from admin area' do
|
84
86
|
before do
|
85
|
-
|
86
|
-
|
87
|
-
|
87
|
+
allow_any_instance_of(ActionController::TestRequest).to receive(:referer) do
|
88
|
+
'/admin_users'
|
89
|
+
end
|
88
90
|
end
|
89
91
|
|
90
92
|
it "redirects to root" do
|
91
|
-
|
93
|
+
delete :destroy
|
92
94
|
is_expected.to redirect_to(root_path)
|
93
95
|
end
|
94
96
|
end
|
95
97
|
|
96
98
|
context 'no referer present' do
|
97
99
|
before do
|
98
|
-
|
99
|
-
|
100
|
-
|
100
|
+
allow_any_instance_of(ActionController::TestRequest).to receive(:referer) do
|
101
|
+
nil
|
102
|
+
end
|
101
103
|
end
|
102
104
|
|
103
105
|
it "redirects to root" do
|
104
|
-
|
106
|
+
delete :destroy
|
105
107
|
is_expected.to redirect_to(root_path)
|
106
108
|
end
|
107
109
|
end
|
108
110
|
|
109
111
|
context 'referer not from admin area' do
|
110
112
|
before do
|
111
|
-
|
112
|
-
|
113
|
-
|
113
|
+
allow_any_instance_of(ActionController::TestRequest).to receive(:referer) do
|
114
|
+
'/imprint'
|
115
|
+
end
|
114
116
|
end
|
115
117
|
|
116
118
|
it "redirects to root" do
|
117
|
-
|
119
|
+
delete :destroy
|
118
120
|
is_expected.to redirect_to('/imprint')
|
119
121
|
end
|
120
122
|
end
|