token_authenticate_me 0.4.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/{LICENSE → MIT-LICENSE} +1 -1
- data/Rakefile +27 -11
- data/app/controllers/token_authenticate_me/api/v1/base_controller.rb +9 -0
- data/app/controllers/token_authenticate_me/api/v1/invites_controller.rb +14 -0
- data/app/controllers/token_authenticate_me/api/v1/password_resets_controller.rb +11 -0
- data/app/controllers/token_authenticate_me/api/v1/sessions_controller.rb +11 -0
- data/app/controllers/token_authenticate_me/api/v1/users_controller.rb +17 -0
- data/app/controllers/token_authenticate_me/application_controller.rb +5 -0
- data/app/helpers/token_authenticate_me/application_helper.rb +4 -0
- data/app/mailers/token_authenticate_me_mailer.rb +16 -9
- data/app/models/token_authenticate_me/invite.rb +11 -0
- data/app/models/token_authenticate_me/session.rb +8 -0
- data/app/models/token_authenticate_me/user.rb +11 -0
- data/app/views/token_authenticate_me_mailer/invite_user_email.html.erb +0 -0
- data/config/routes.rb +23 -0
- data/db/migrate/20160620184327_create_token_authenticate_me_invites.rb +14 -0
- data/db/migrate/20160621211347_create_token_authenticate_me_users.rb +18 -0
- data/db/migrate/20160622203801_create_token_authenticate_me_sessions.rb +14 -0
- data/lib/generators/token_authenticate_me/controllers/controllers_generator.rb +1 -76
- data/lib/generators/token_authenticate_me/install/install_generator.rb +9 -3
- data/lib/generators/token_authenticate_me/models/models_generator.rb +1 -59
- data/lib/generators/token_authenticate_me/policies/policies_generator.rb +15 -0
- data/lib/generators/token_authenticate_me/policies/templates/invite_policy.rb +31 -0
- data/lib/generators/token_authenticate_me/policies/templates/user_policy.rb +23 -0
- data/lib/tasks/token_authenticate_me_tasks.rake +4 -0
- data/lib/token_authenticate_me.rb +11 -0
- data/lib/token_authenticate_me/concerns/controllers/invitable.rb +58 -0
- data/lib/token_authenticate_me/concerns/controllers/password_resetable.rb +97 -0
- data/lib/token_authenticate_me/concerns/controllers/sessionable.rb +55 -0
- data/lib/token_authenticate_me/concerns/controllers/token_authenticateable.rb +45 -0
- data/lib/token_authenticate_me/concerns/models/authenticatable.rb +102 -0
- data/lib/token_authenticate_me/concerns/models/invitable.rb +20 -0
- data/lib/token_authenticate_me/concerns/models/sessionable.rb +44 -0
- data/lib/token_authenticate_me/configuration.rb +16 -0
- data/lib/token_authenticate_me/engine.rb +2 -2
- data/lib/token_authenticate_me/models.rb +4 -0
- data/lib/token_authenticate_me/version.rb +1 -1
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/{spec/internal → test/dummy}/app/controllers/application_controller.rb +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +25 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/log/test.log +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/fixtures/token_authenticate_me/invites.yml +11 -0
- data/test/fixtures/token_authenticate_me/sessions.yml +11 -0
- data/test/fixtures/token_authenticate_me/users.yml +11 -0
- data/test/integration/navigation_test.rb +7 -0
- data/test/models/token_authenticate_me/invite_test.rb +9 -0
- data/test/models/token_authenticate_me/session_test.rb +9 -0
- data/test/models/token_authenticate_me/user_test.rb +9 -0
- data/test/test_helper.rb +21 -0
- data/test/token_authenticate_me_test.rb +7 -0
- metadata +129 -160
- data/.editorconfig +0 -41
- data/.gitignore +0 -4
- data/.rubocop.yml +0 -8
- data/CHANGELOG.md +0 -2
- data/Gemfile +0 -7
- data/config.ru +0 -7
- data/lib/generators/token_authenticate_me/controllers/templates/password_reset.rb +0 -6
- data/lib/generators/token_authenticate_me/controllers/templates/sessions.rb +0 -6
- data/lib/generators/token_authenticate_me/controllers/templates/users.rb +0 -8
- data/lib/generators/token_authenticate_me/models/templates/authentication_migration.rb +0 -20
- data/lib/generators/token_authenticate_me/models/templates/authentication_model.rb +0 -11
- data/lib/generators/token_authenticate_me/models/templates/session_migration.rb +0 -17
- data/lib/generators/token_authenticate_me/models/templates/session_model.rb +0 -12
- data/lib/token_authenticate_me/controllers/password_resetable.rb +0 -95
- data/lib/token_authenticate_me/controllers/sessionable.rb +0 -53
- data/lib/token_authenticate_me/controllers/token_authenticateable.rb +0 -52
- data/lib/token_authenticate_me/models/authenticatable.rb +0 -93
- data/lib/token_authenticate_me/models/sessionable.rb +0 -36
- data/spec/acceptance/password_reset_api_spec.rb +0 -111
- data/spec/acceptance/session_api_spec.rb +0 -95
- data/spec/acceptance/users_api_spec.rb +0 -70
- data/spec/internal/app/controllers/password_resets_controller.rb +0 -5
- data/spec/internal/app/controllers/sessions_controller.rb +0 -5
- data/spec/internal/app/controllers/users_controller.rb +0 -7
- data/spec/internal/app/models/session.rb +0 -11
- data/spec/internal/app/models/user.rb +0 -11
- data/spec/internal/app/policies/user_policy.rb +0 -29
- data/spec/internal/app/serializers/user_serializer.rb +0 -3
- data/spec/internal/config/database.yml +0 -3
- data/spec/internal/config/routes.rb +0 -13
- data/spec/internal/db/fixtures/users.rb +0 -11
- data/spec/internal/db/schema.rb +0 -19
- data/spec/spec_helper.rb +0 -38
- data/token_authenticate_me.gemspec +0 -32
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe 'Password Reset API' do
|
|
4
|
-
it 'resets the users password when called with the correct token' do
|
|
5
|
-
user = create_user
|
|
6
|
-
|
|
7
|
-
user.create_reset_token!
|
|
8
|
-
encrypted_pw = user.password_digest
|
|
9
|
-
reset_token = user.reset_password_token.to_s
|
|
10
|
-
|
|
11
|
-
put '/password_resets/' + reset_token + '/',
|
|
12
|
-
password: 'test', password_confirmation: 'test'
|
|
13
|
-
|
|
14
|
-
expect(last_response.status).to eq(204)
|
|
15
|
-
expect(User.find(user.id).password_digest).not_to eq(encrypted_pw)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it 'does not allow replay attacks' do
|
|
19
|
-
user = create_user
|
|
20
|
-
|
|
21
|
-
user.create_reset_token!
|
|
22
|
-
encrypted_pw = user.password_digest
|
|
23
|
-
reset_token = user.reset_password_token.to_s
|
|
24
|
-
|
|
25
|
-
put '/password_resets/' + reset_token + '/',
|
|
26
|
-
password: 'test', password_confirmation: 'test'
|
|
27
|
-
|
|
28
|
-
expect(last_response.status).to eq(204)
|
|
29
|
-
expect(User.find(user.id).password_digest).not_to eq(encrypted_pw)
|
|
30
|
-
|
|
31
|
-
put '/password_resets/' + reset_token + '/',
|
|
32
|
-
password: 'test', password_confirmation: 'test'
|
|
33
|
-
expect(last_response.status).to eq(404)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it 'fails to reset the users password when the confirmation does not match' do
|
|
37
|
-
user = create_user
|
|
38
|
-
|
|
39
|
-
user.create_reset_token!
|
|
40
|
-
encrypted_pw = user.password_digest
|
|
41
|
-
reset_token = user.reset_password_token.to_s
|
|
42
|
-
|
|
43
|
-
put '/password_resets/' + reset_token + '/',
|
|
44
|
-
password: 'test', password_confirmation: 'test_ops'
|
|
45
|
-
|
|
46
|
-
expect(last_response.status).to eq(422)
|
|
47
|
-
expect(User.find(user.id).password_digest).to eq(encrypted_pw)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it 'raises a routing error when called with an empty token' do
|
|
51
|
-
user = create_user
|
|
52
|
-
|
|
53
|
-
user.create_reset_token!
|
|
54
|
-
encrypted_pw = user.password_digest
|
|
55
|
-
|
|
56
|
-
expect do
|
|
57
|
-
put '/password_resets//', password: 'test', password_confirmation: 'test'
|
|
58
|
-
end.to raise_error(ActionController::RoutingError)
|
|
59
|
-
expect(User.find(user.id).password_digest).to eq(encrypted_pw)
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
it 'returns a 404 when reset is requested with a bad token' do
|
|
63
|
-
user = create_user
|
|
64
|
-
|
|
65
|
-
user.create_reset_token!
|
|
66
|
-
|
|
67
|
-
put '/password_resets/' + SecureRandom.hex.to_s + '/',
|
|
68
|
-
password: 'test', password_confirmation: 'test'
|
|
69
|
-
|
|
70
|
-
expect(last_response.status).to eq(404)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it 'returns a 204 when a password reset is requested with a valid e-mail' do
|
|
74
|
-
user = create_user
|
|
75
|
-
|
|
76
|
-
post '/password_resets/', email: user.email
|
|
77
|
-
|
|
78
|
-
expect(last_response.status).to eq(204)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
it 'returns a 204 when a password reset is requested with a invalid e-mail' do
|
|
82
|
-
user = create_user # rubocop:disable Lint/UselessAssignment
|
|
83
|
-
|
|
84
|
-
post '/password_resets/', email: 'foo@bar.com'
|
|
85
|
-
|
|
86
|
-
expect(last_response.status).to eq(204)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it 'sends a valid e-mail when a password reset is requested with a valid e-mail' do
|
|
90
|
-
user = create_user
|
|
91
|
-
|
|
92
|
-
post '/password_resets/', email: user.email
|
|
93
|
-
|
|
94
|
-
mail = ActionMailer::Base.deliveries.last
|
|
95
|
-
|
|
96
|
-
expect(mail['to'].to_s).to eq(user.email)
|
|
97
|
-
expect(mail['subject'].to_s).to eq('Password Reset')
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
it 'sends a invalid e-mail when a password reset is requested with a invalid e-mail' do
|
|
101
|
-
user = create_user # rubocop:disable Lint/UselessAssignment
|
|
102
|
-
email = 'foo@bar.com'
|
|
103
|
-
|
|
104
|
-
post '/password_resets/', email: email
|
|
105
|
-
|
|
106
|
-
mail = ActionMailer::Base.deliveries.last
|
|
107
|
-
|
|
108
|
-
expect(mail['to'].to_s).to eq(email)
|
|
109
|
-
expect(mail['subject'].to_s).to eq('Password Reset Error')
|
|
110
|
-
end
|
|
111
|
-
end
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe 'Session API' do
|
|
4
|
-
it 'creates a new session when authenticating with a username and password' do
|
|
5
|
-
password = 'text'
|
|
6
|
-
user = create_user(password: password)
|
|
7
|
-
|
|
8
|
-
post '/session/',
|
|
9
|
-
username: user.username, password: password
|
|
10
|
-
|
|
11
|
-
expect(last_response.status).to eq(201)
|
|
12
|
-
json = JSON.parse(last_response.body)
|
|
13
|
-
|
|
14
|
-
expect(json['session']).not_to be_nil
|
|
15
|
-
expect(json['session']['key']).not_to be_nil
|
|
16
|
-
expect(json['session']['expiration']).not_to be_nil
|
|
17
|
-
expect(user.id).to eq(json['session']['user']['id'])
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it 'creates a new session when authenticating with a email and password' do
|
|
21
|
-
password = 'text'
|
|
22
|
-
user = create_user(password: password)
|
|
23
|
-
|
|
24
|
-
post '/session/',
|
|
25
|
-
username: user.email, password: password
|
|
26
|
-
|
|
27
|
-
expect(last_response.status).to eq(201)
|
|
28
|
-
json = JSON.parse(last_response.body)
|
|
29
|
-
|
|
30
|
-
expect(json['session']).not_to be_nil
|
|
31
|
-
expect(json['session']['key']).not_to be_nil
|
|
32
|
-
expect(json['session']['expiration']).not_to be_nil
|
|
33
|
-
expect(user.id).to eq(json['session']['user']['id'])
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it 'fails to create a new session when authenticating with an invalid password' do
|
|
37
|
-
password = 'text'
|
|
38
|
-
user = create_user(password: password)
|
|
39
|
-
|
|
40
|
-
post '/session/',
|
|
41
|
-
username: user.email, password: 'not_test'
|
|
42
|
-
|
|
43
|
-
expect(last_response.status).to eq(401)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it 'fetches an existing session when authenticated' do
|
|
47
|
-
password = 'text'
|
|
48
|
-
user = create_user(password: password)
|
|
49
|
-
|
|
50
|
-
post '/session/',
|
|
51
|
-
username: user.email, password: password
|
|
52
|
-
expect(last_response.status).to eq(201)
|
|
53
|
-
json = JSON.parse(last_response.body)
|
|
54
|
-
|
|
55
|
-
header 'Authorization', 'Token token=' + json['session']['key']
|
|
56
|
-
get '/session/'
|
|
57
|
-
expect(last_response.status).to eq(200)
|
|
58
|
-
|
|
59
|
-
json = JSON.parse(last_response.body)
|
|
60
|
-
|
|
61
|
-
expect(json['session']).not_to be_nil
|
|
62
|
-
expect(json['session']['key']).not_to be_nil
|
|
63
|
-
expect(json['session']['expiration']).not_to be_nil
|
|
64
|
-
expect(user.id).to eq(json['session']['user']['id'])
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it 'fetching an expired session fails' do
|
|
68
|
-
user = create_user
|
|
69
|
-
session = Session.create!(user_id: user.id)
|
|
70
|
-
session.update!(expiration: 5.minutes.ago)
|
|
71
|
-
|
|
72
|
-
header 'Authorization', 'Token token=' + session.key
|
|
73
|
-
get '/session/'
|
|
74
|
-
expect(last_response.status).to eq(401)
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it 'destroying an existing session succeeds' do
|
|
78
|
-
user = create_user
|
|
79
|
-
session = Session.create!(user_id: user.id)
|
|
80
|
-
|
|
81
|
-
header 'Authorization', 'Token token=' + session.key
|
|
82
|
-
delete '/session/'
|
|
83
|
-
expect(last_response.status).to eq(204)
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
it 'destroying an expired session fails' do
|
|
87
|
-
user = create_user
|
|
88
|
-
session = Session.create!(user_id: user.id)
|
|
89
|
-
session.update!(expiration: 5.minutes.ago)
|
|
90
|
-
|
|
91
|
-
header 'Authorization', 'Token token=' + session.key
|
|
92
|
-
delete '/session/'
|
|
93
|
-
expect(last_response.status).to eq(401)
|
|
94
|
-
end
|
|
95
|
-
end
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe 'Users API' do
|
|
4
|
-
it 'creates a new user when unauthenticated' do
|
|
5
|
-
username = 'test'
|
|
6
|
-
password = 'test'
|
|
7
|
-
email = 'test'
|
|
8
|
-
|
|
9
|
-
post '/users/',
|
|
10
|
-
user: {
|
|
11
|
-
username: username,
|
|
12
|
-
password: password,
|
|
13
|
-
password_confirmation: password,
|
|
14
|
-
email: email
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
expect(last_response.status).to eq(201)
|
|
18
|
-
json = JSON.parse(last_response.body)
|
|
19
|
-
|
|
20
|
-
expect(json['user']).not_to be_nil
|
|
21
|
-
expect(json['user']['username']).to eq(username)
|
|
22
|
-
expect(json['user']['email']).to eq(email)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'fails to create a new user when the password confirmation does not match' do
|
|
26
|
-
username = 'test'
|
|
27
|
-
password = 'test'
|
|
28
|
-
email = 'test'
|
|
29
|
-
|
|
30
|
-
post '/users/',
|
|
31
|
-
user: {
|
|
32
|
-
username: username,
|
|
33
|
-
password: password,
|
|
34
|
-
password_confirmation: 'invalid',
|
|
35
|
-
email: email
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
expect(last_response.status).to eq(422)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it 'succeeds to list users when authenticated' do
|
|
42
|
-
user = create_user
|
|
43
|
-
session = Session.create!(user_id: user.id)
|
|
44
|
-
|
|
45
|
-
header 'Authorization', 'Token token=' + session.key
|
|
46
|
-
get '/users/'
|
|
47
|
-
|
|
48
|
-
expect(last_response.status).to eq(200)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it 'fails to list users without being authenticated' do
|
|
52
|
-
get '/users/'
|
|
53
|
-
|
|
54
|
-
expect(last_response.status).to eq(401)
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it 'does not serialze password digest' do
|
|
58
|
-
user = create_user
|
|
59
|
-
session = Session.create!(user_id: user.id)
|
|
60
|
-
|
|
61
|
-
header 'Authorization', 'Token token=' + session.key
|
|
62
|
-
get '/users/' + user.id.to_s + '/'
|
|
63
|
-
|
|
64
|
-
expect(last_response.status).to eq(200)
|
|
65
|
-
json = JSON.parse(last_response.body)
|
|
66
|
-
|
|
67
|
-
expect(json['user']).not_to be_nil
|
|
68
|
-
expect(json['user']['password_digest']).to be_nil
|
|
69
|
-
end
|
|
70
|
-
end
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
require 'token_authenticate_me/models/sessionable'
|
|
2
|
-
|
|
3
|
-
class Session < ActiveRecord::Base
|
|
4
|
-
include TokenAuthenticateMe::Models::Sessionable
|
|
5
|
-
|
|
6
|
-
belongs_to :user
|
|
7
|
-
|
|
8
|
-
def as_json(options = {})
|
|
9
|
-
{ session: super({ include: :user }.merge(options)) }
|
|
10
|
-
end
|
|
11
|
-
end
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
class UserPolicy
|
|
2
|
-
def initialize(*)
|
|
3
|
-
end
|
|
4
|
-
|
|
5
|
-
def permitted_attributes
|
|
6
|
-
[:username, :email, :password, :password_confirmation]
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def create?
|
|
10
|
-
true
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def show?
|
|
14
|
-
true
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
class Scope
|
|
18
|
-
attr_reader :user, :scope
|
|
19
|
-
|
|
20
|
-
def initialize(user, scope)
|
|
21
|
-
@user = user
|
|
22
|
-
@scope = scope
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def resolve
|
|
26
|
-
scope
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
data/spec/internal/db/schema.rb
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
ActiveRecord::Schema.define do
|
|
2
|
-
create_table :users, force: true do |t|
|
|
3
|
-
t.string :username, null: false
|
|
4
|
-
t.string :email, null: false
|
|
5
|
-
t.string :password_digest, null: false
|
|
6
|
-
t.string :reset_password_token
|
|
7
|
-
t.datetime :reset_password_token_exp
|
|
8
|
-
|
|
9
|
-
t.timestamps
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
create_table :sessions, force: true do |t|
|
|
13
|
-
t.string :key, null: false
|
|
14
|
-
t.datetime :expiration
|
|
15
|
-
t.integer :user_id
|
|
16
|
-
|
|
17
|
-
t.timestamps
|
|
18
|
-
end
|
|
19
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
require 'rubygems'
|
|
2
|
-
require 'bundler/setup'
|
|
3
|
-
require 'combustion'
|
|
4
|
-
|
|
5
|
-
Bundler.require :default, :development
|
|
6
|
-
|
|
7
|
-
Combustion.initialize! :active_record, :action_controller, :action_mailer, :action_view
|
|
8
|
-
|
|
9
|
-
require 'rspec/rails'
|
|
10
|
-
require 'rack/test'
|
|
11
|
-
|
|
12
|
-
# Load fixture helpers for testing
|
|
13
|
-
Dir[File.join(File.dirname(__FILE__), 'internal', 'db', 'fixtures', '**', '*.rb')].each do |file|
|
|
14
|
-
require file
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
module ApiHelper
|
|
18
|
-
include Rack::Test::Methods
|
|
19
|
-
|
|
20
|
-
def app
|
|
21
|
-
Rails.application
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
RSpec.configure do |config|
|
|
26
|
-
config.use_transactional_fixtures = true
|
|
27
|
-
config.mock_with :rspec
|
|
28
|
-
|
|
29
|
-
config.before do
|
|
30
|
-
ActionMailer::Base.delivery_method = :test
|
|
31
|
-
ActionMailer::Base.default_options = {
|
|
32
|
-
from: 'no-reply@test.com'
|
|
33
|
-
}
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
config.include ApiHelper
|
|
37
|
-
config.include Fixtures::Users
|
|
38
|
-
end
|