bsm_oa 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/Gemfile +6 -0
- data/Gemfile.lock +138 -142
- data/app/controllers/bsm_oa/accounts_controller.rb +19 -4
- data/app/controllers/bsm_oa/admin_controller.rb +5 -0
- data/app/controllers/bsm_oa/applications_controller.rb +36 -15
- data/app/controllers/bsm_oa/authorizations_controller.rb +7 -6
- data/app/controllers/bsm_oa/base_controller.rb +5 -0
- data/app/controllers/bsm_oa/roles_controller.rb +3 -4
- data/app/views/bsm_oa/applications/_application.html.erb +2 -2
- data/app/views/bsm_oa/applications/_inputs.html.erb +6 -11
- data/app/views/bsm_oa/applications/edit.html.erb +2 -2
- data/app/views/bsm_oa/applications/index.html.erb +1 -1
- data/app/views/bsm_oa/applications/new.html.erb +2 -2
- data/app/views/bsm_oa/applications/show.html.erb +40 -0
- data/app/views/bsm_oa/authorizations/_inputs.html.erb +2 -2
- data/app/views/bsm_oa/authorizations/edit.html.erb +1 -1
- data/app/views/bsm_oa/authorizations/new.html.erb +2 -3
- data/app/views/bsm_oa/roles/_inputs.html.erb +3 -4
- data/app/views/bsm_oa/roles/edit.html.erb +1 -1
- data/app/views/bsm_oa/roles/new.html.erb +1 -1
- data/app/views/bsm_oa/roles/show.html.erb +1 -1
- data/bsm_oa.gemspec +6 -11
- data/db/migrate/20150507113313_bsm_oa_create_doorkeeper_tables.rb +1 -1
- data/db/migrate/20150513155732_bsm_oa_create_tables.rb +1 -1
- data/lib/bsm_oa.rb +0 -3
- data/lib/bsm_oa/application.rb +31 -0
- data/lib/bsm_oa/authorization.rb +8 -15
- data/lib/bsm_oa/config.rb +5 -0
- data/lib/bsm_oa/engine.rb +2 -4
- data/lib/bsm_oa/role.rb +1 -1
- data/lib/bsm_oa/routes.rb +29 -3
- data/lib/bsm_oa/version.rb +1 -1
- data/spec/controllers/bsm_oa/accounts_controller_spec.rb +15 -12
- data/spec/controllers/bsm_oa/applications_controller_spec.rb +22 -28
- data/spec/controllers/bsm_oa/authorizations_controller_spec.rb +17 -22
- data/spec/controllers/bsm_oa/roles_controller_spec.rb +14 -16
- data/spec/factories.rb +1 -1
- data/spec/lib/bsm_oa/{application_mixin_spec.rb → application_spec.rb} +13 -9
- data/spec/lib/bsm_oa/authorization_spec.rb +5 -9
- data/spec/lib/bsm_oa/role_spec.rb +1 -1
- data/spec/spec_helper.rb +18 -8
- metadata +22 -104
- data/app/views/bsm_oa/accounts/show.json.jbuilder +0 -7
- data/app/views/bsm_oa/applications/_application.json.jbuilder +0 -1
- data/app/views/bsm_oa/applications/create.json.jbuilder +0 -1
- data/app/views/bsm_oa/applications/index.json.jbuilder +0 -1
- data/app/views/bsm_oa/applications/show.json.jbuilder +0 -1
- data/app/views/bsm_oa/applications/update.json.jbuilder +0 -1
- data/app/views/bsm_oa/authorizations/_authorization.json.jbuilder +0 -1
- data/app/views/bsm_oa/authorizations/index.json.jbuilder +0 -1
- data/app/views/bsm_oa/authorizations/toggle.json.jbuilder +0 -1
- data/lib/bsm_oa/application_mixin.rb +0 -37
data/lib/bsm_oa/version.rb
CHANGED
@@ -1,35 +1,38 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BsmOa::AccountsController, type: :controller do
|
4
|
+
include Rack::Test::Methods
|
4
5
|
|
5
6
|
let(:authorization) { create :authorization }
|
6
7
|
let(:application) { authorization.application }
|
7
8
|
let(:user) { create :user, roles: [authorization.role] }
|
8
9
|
let(:access_token) { Doorkeeper::AccessToken.create! resource_owner_id: user.id, application_id: application.id }
|
10
|
+
let(:app) { Rails.application }
|
9
11
|
|
10
|
-
describe '
|
11
|
-
|
12
|
+
describe 'GET show.json (successful)' do
|
13
|
+
before do
|
14
|
+
get "/me.json", {client_id: application.uid, client_secret: application.secret}, {"HTTP_AUTHORIZATION" => "Bearer #{access_token.token}"}
|
15
|
+
end
|
16
|
+
|
17
|
+
it { expect(last_response.status).to eq(200) }
|
18
|
+
it { expect(last_response.headers).to include("Content-Type" => "application/json; charset=utf-8") }
|
12
19
|
end
|
13
20
|
|
14
|
-
describe 'GET show.json (
|
21
|
+
describe 'GET show.json (expired)' do
|
15
22
|
before do
|
16
|
-
|
17
|
-
get
|
23
|
+
access_token.update_column :resource_owner_id, 0
|
24
|
+
get "/me.json", {client_id: application.uid, client_secret: application.secret}, {"HTTP_AUTHORIZATION" => "Bearer #{access_token.token}"}
|
18
25
|
end
|
19
26
|
|
20
|
-
it { expect(
|
21
|
-
it { expect(response.body).to have_json_size(1).at_path('authorizations') }
|
22
|
-
it { expect(response.body).to have_json_size(2).at_path('authorizations/0') }
|
23
|
-
it { is_expected.to respond_with(:success) }
|
27
|
+
it { expect(last_response.status).to eq(403) }
|
24
28
|
end
|
25
29
|
|
26
30
|
describe 'GET show.json (bad auth token)' do
|
27
31
|
before do
|
28
|
-
|
29
|
-
get :show, format: 'json'
|
32
|
+
get "/me.json", {client_id: application.uid, client_secret: application.secret}, {"HTTP_AUTHORIZATION" => "Bearer abcdef"}
|
30
33
|
end
|
31
34
|
|
32
|
-
it {
|
35
|
+
it { expect(last_response.status).to eq(401) }
|
33
36
|
end
|
34
37
|
|
35
38
|
end
|
@@ -6,12 +6,12 @@ describe BsmOa::ApplicationsController, type: :controller do
|
|
6
6
|
let(:application) { create :application }
|
7
7
|
|
8
8
|
describe 'routing' do
|
9
|
-
it { is_expected.to route(:get,
|
10
|
-
it { is_expected.to route(:post,
|
11
|
-
it { is_expected.to route(:get,
|
12
|
-
it { is_expected.to route(:get,
|
13
|
-
it { is_expected.to route(:put,
|
14
|
-
it { is_expected.to route(:delete,
|
9
|
+
it { is_expected.to route(:get, "/applications") .to(action: :index) }
|
10
|
+
it { is_expected.to route(:post, "/applications") .to(action: :create) }
|
11
|
+
it { is_expected.to route(:get, "/applications/new") .to(action: :new) }
|
12
|
+
it { is_expected.to route(:get, "/applications/1") .to(action: :show, id: 1) }
|
13
|
+
it { is_expected.to route(:put, "/applications/1") .to(action: :update, id: 1) }
|
14
|
+
it { is_expected.to route(:delete, "/applications/1") .to(action: :destroy, id: 1) }
|
15
15
|
end
|
16
16
|
|
17
17
|
describe 'GET index.json' do
|
@@ -20,84 +20,78 @@ describe BsmOa::ApplicationsController, type: :controller do
|
|
20
20
|
get :index, format: 'json'
|
21
21
|
end
|
22
22
|
|
23
|
-
it { expect(response.body).to have_json_size(1) }
|
24
23
|
it { is_expected.to respond_with(:success) }
|
25
24
|
end
|
26
25
|
|
27
26
|
describe 'GET show.json' do
|
28
27
|
before do
|
29
|
-
get :show, format: 'json', id: application.to_param
|
28
|
+
get :show, params: {format: 'json', id: application.to_param}
|
30
29
|
end
|
31
30
|
|
32
|
-
it { expect(response.body).to have_json_size(6) }
|
33
31
|
it { is_expected.to respond_with(:success) }
|
34
32
|
end
|
35
33
|
|
36
34
|
describe 'GET show.html' do
|
37
35
|
before do
|
38
|
-
get :show, format: 'html', id: application.to_param
|
36
|
+
get :show, params: {format: 'html', id: application.to_param}
|
39
37
|
end
|
40
38
|
|
41
|
-
it { is_expected.to
|
39
|
+
it { is_expected.to respond_with(:success) }
|
42
40
|
end
|
43
41
|
|
44
42
|
describe 'POST create.json (successful)' do
|
45
43
|
before do
|
46
|
-
post :create, format: 'json',
|
44
|
+
post :create, params: {format: 'json', bsm_oa_application: attributes_for(:application)}
|
47
45
|
end
|
48
46
|
|
49
|
-
it {
|
50
|
-
it { is_expected.to respond_with(:success) }
|
47
|
+
it { is_expected.to respond_with(:created) }
|
51
48
|
end
|
52
49
|
|
53
50
|
describe 'POST create.json (unsuccessful)' do
|
54
51
|
before do
|
55
|
-
post :create, format: 'json',
|
52
|
+
post :create, params: {format: 'json', bsm_oa_application: attributes_for(:application, name: nil)}
|
56
53
|
end
|
57
54
|
|
58
|
-
it { expect(response.body).to have_json_path('errors') }
|
59
55
|
it { is_expected.to respond_with(:unprocessable_entity) }
|
60
56
|
end
|
61
57
|
|
62
58
|
describe 'POST create.html' do
|
63
59
|
before do
|
64
|
-
post :create,
|
60
|
+
post :create, params: {bsm_oa_application: attributes_for(:application)}
|
65
61
|
end
|
66
62
|
|
67
63
|
it { is_expected.to respond_with(:redirect) }
|
68
|
-
it { is_expected.to redirect_to("http://test.host/
|
64
|
+
it { is_expected.to redirect_to("http://test.host/applications/#{BsmOa::Application.last.to_param}") }
|
69
65
|
end
|
70
66
|
|
71
67
|
describe 'PUT update.json (successful)' do
|
72
68
|
before do
|
73
|
-
put :update, format: 'json', id: application.to_param,
|
69
|
+
put :update, params: {format: 'json', id: application.to_param, bsm_oa_application: application.attributes}
|
74
70
|
end
|
75
71
|
|
76
|
-
it {
|
77
|
-
it { is_expected.to respond_with(:success) }
|
72
|
+
it { is_expected.to respond_with(:no_content) }
|
78
73
|
end
|
79
74
|
|
80
75
|
describe 'PUT update.json (unsuccessful)' do
|
81
76
|
before do
|
82
|
-
put :update, format: 'json', id: application.to_param,
|
77
|
+
put :update, params: {format: 'json', id: application.to_param, bsm_oa_application: build(:application, name: nil).attributes}
|
83
78
|
end
|
84
79
|
|
85
|
-
it { expect(response.body).to have_json_path('errors') }
|
86
80
|
it { is_expected.to respond_with(:unprocessable_entity) }
|
87
81
|
end
|
88
82
|
|
89
83
|
describe 'PUT update.html' do
|
90
84
|
before do
|
91
|
-
put :update, id: application.to_param,
|
85
|
+
put :update, params: {id: application.to_param, bsm_oa_application: application.attributes}
|
92
86
|
end
|
93
87
|
|
94
88
|
it { is_expected.to respond_with(:redirect) }
|
95
|
-
it { is_expected.to redirect_to("http://test.host/
|
89
|
+
it { is_expected.to redirect_to("http://test.host/applications/#{application.to_param}") }
|
96
90
|
end
|
97
91
|
|
98
92
|
describe 'DELETE destroy.json' do
|
99
93
|
before do
|
100
|
-
delete :destroy, format: 'json', id: application.to_param
|
94
|
+
delete :destroy, params: {format: 'json', id: application.to_param}
|
101
95
|
end
|
102
96
|
|
103
97
|
it { is_expected.to respond_with(:no_content) }
|
@@ -105,10 +99,10 @@ describe BsmOa::ApplicationsController, type: :controller do
|
|
105
99
|
|
106
100
|
describe 'DELETE destroy.html' do
|
107
101
|
before do
|
108
|
-
delete :destroy, id: application.to_param
|
102
|
+
delete :destroy, params: {id: application.to_param}
|
109
103
|
end
|
110
104
|
|
111
105
|
it { is_expected.to respond_with(:redirect) }
|
112
|
-
it { is_expected.to redirect_to("http://test.host/
|
106
|
+
it { is_expected.to redirect_to("http://test.host/applications") }
|
113
107
|
end
|
114
108
|
end
|
@@ -19,18 +19,16 @@ describe BsmOa::AuthorizationsController, type: :controller do
|
|
19
19
|
describe 'GET index.json' do
|
20
20
|
before do
|
21
21
|
resource
|
22
|
-
get :index, bsm_oa_role_id: role.to_param, format: 'json'
|
22
|
+
get :index, params: {bsm_oa_role_id: role.to_param, format: 'json'}
|
23
23
|
end
|
24
24
|
|
25
25
|
it { is_expected.to respond_with(:success) }
|
26
|
-
it { expect(response.body).to have_json_size(1) }
|
27
|
-
it { expect(response.body).to have_json_size(3).at_path('0') }
|
28
26
|
end
|
29
27
|
|
30
28
|
describe 'GET index.html' do
|
31
29
|
before do
|
32
30
|
resource
|
33
|
-
get :index, bsm_oa_role_id: role.to_param
|
31
|
+
get :index, params: {bsm_oa_role_id: role.to_param}
|
34
32
|
end
|
35
33
|
|
36
34
|
it { is_expected.to render_template(:index) }
|
@@ -39,7 +37,7 @@ describe BsmOa::AuthorizationsController, type: :controller do
|
|
39
37
|
|
40
38
|
describe 'GET new.html' do
|
41
39
|
before do
|
42
|
-
get :new, bsm_oa_role_id: role.to_param
|
40
|
+
get :new, params: {bsm_oa_role_id: role.to_param}
|
43
41
|
end
|
44
42
|
it { is_expected.to render_template(:new) }
|
45
43
|
it { is_expected.to respond_with(:success) }
|
@@ -47,22 +45,21 @@ describe BsmOa::AuthorizationsController, type: :controller do
|
|
47
45
|
|
48
46
|
describe 'GET show.html' do
|
49
47
|
before do
|
50
|
-
get :show, id: resource.to_param
|
48
|
+
get :show, params: {id: resource.to_param}
|
51
49
|
end
|
52
50
|
it { is_expected.to redirect_to("/roles/#{resource.role.to_param}") }
|
53
51
|
end
|
54
52
|
|
55
53
|
describe 'GET show.json' do
|
56
54
|
before do
|
57
|
-
get :show, id: resource.to_param, format: "json"
|
55
|
+
get :show, params: {id: resource.to_param, format: "json"}
|
58
56
|
end
|
59
57
|
it { is_expected.to respond_with(:success) }
|
60
|
-
it { expect(response.body).to have_json_size(4) }
|
61
58
|
end
|
62
59
|
|
63
60
|
describe 'GET edit.html' do
|
64
61
|
before do
|
65
|
-
get :edit, id: resource.to_param
|
62
|
+
get :edit, params: {id: resource.to_param}
|
66
63
|
end
|
67
64
|
it { is_expected.to render_template(:edit) }
|
68
65
|
it { is_expected.to respond_with(:success) }
|
@@ -71,17 +68,16 @@ describe BsmOa::AuthorizationsController, type: :controller do
|
|
71
68
|
describe 'POST create.json (successful)' do
|
72
69
|
before do
|
73
70
|
role = create(:role)
|
74
|
-
post :create, format: 'json', bsm_oa_role_id: role.to_param,
|
71
|
+
post :create, params: {format: 'json', bsm_oa_role_id: role.to_param, bsm_oa_authorization: resource.attributes.merge( permissions: 'admin')}
|
75
72
|
end
|
76
73
|
|
77
74
|
it { is_expected.to respond_with(:created) }
|
78
|
-
it { expect(response.body).to have_json_size(4) }
|
79
75
|
end
|
80
76
|
|
81
77
|
describe 'POST create.html (successful)' do
|
82
78
|
before do
|
83
79
|
role = create(:role)
|
84
|
-
post :create,
|
80
|
+
post :create, params: {bsm_oa_authorization: resource.attributes.merge( permissions: 'admin'), bsm_oa_role_id: role.to_param}
|
85
81
|
end
|
86
82
|
|
87
83
|
it { is_expected.to respond_with(:redirect) }
|
@@ -91,7 +87,7 @@ describe BsmOa::AuthorizationsController, type: :controller do
|
|
91
87
|
describe 'POST create.html (unsuccessful)' do
|
92
88
|
before do
|
93
89
|
role = create(:role)
|
94
|
-
post :create, bsm_oa_role_id: role.to_param,
|
90
|
+
post :create, params: {bsm_oa_role_id: role.to_param, bsm_oa_authorization: { application_id: '' }}
|
95
91
|
end
|
96
92
|
|
97
93
|
it { is_expected.to respond_with(:success) }
|
@@ -100,7 +96,7 @@ describe BsmOa::AuthorizationsController, type: :controller do
|
|
100
96
|
|
101
97
|
describe 'PUT update.html (successful)' do
|
102
98
|
before do
|
103
|
-
put :update, id: resource.to_param,
|
99
|
+
put :update, params: {id: resource.to_param, bsm_oa_authorization: { permissions: 'admin' }}
|
104
100
|
end
|
105
101
|
|
106
102
|
it { is_expected.to respond_with(:redirect) }
|
@@ -109,7 +105,7 @@ describe BsmOa::AuthorizationsController, type: :controller do
|
|
109
105
|
|
110
106
|
describe 'PUT update.html (unsuccessful)' do
|
111
107
|
before do
|
112
|
-
put :update, id: resource.to_param,
|
108
|
+
put :update, params: {id: resource.to_param, bsm_oa_authorization: { application_id: '0' }}
|
113
109
|
end
|
114
110
|
|
115
111
|
it { is_expected.to respond_with(:success) }
|
@@ -118,7 +114,7 @@ describe BsmOa::AuthorizationsController, type: :controller do
|
|
118
114
|
|
119
115
|
describe 'PUT update.json (successful)' do
|
120
116
|
before do
|
121
|
-
put :update, format: 'json', id: resource.to_param,
|
117
|
+
put :update, params: {format: 'json', id: resource.to_param, bsm_oa_authorization: { permissions: 'admin' }}
|
122
118
|
end
|
123
119
|
|
124
120
|
it { is_expected.to respond_with(:no_content) }
|
@@ -126,7 +122,7 @@ describe BsmOa::AuthorizationsController, type: :controller do
|
|
126
122
|
|
127
123
|
describe 'PUT update.json (unsuccessful)' do
|
128
124
|
before do
|
129
|
-
put :update, format: 'json', id: resource.to_param,
|
125
|
+
put :update, params: {format: 'json', id: resource.to_param, bsm_oa_authorization: { application_id: '0' }}
|
130
126
|
end
|
131
127
|
|
132
128
|
it { is_expected.to respond_with(:unprocessable_entity) }
|
@@ -134,7 +130,7 @@ describe BsmOa::AuthorizationsController, type: :controller do
|
|
134
130
|
|
135
131
|
describe 'PUT toggle' do
|
136
132
|
before do
|
137
|
-
put :toggle, id: resource.to_param, permission: "admin"
|
133
|
+
put :toggle, params: {id: resource.to_param, permission: "admin"}
|
138
134
|
end
|
139
135
|
|
140
136
|
it { is_expected.to respond_with(:redirect) }
|
@@ -143,7 +139,7 @@ describe BsmOa::AuthorizationsController, type: :controller do
|
|
143
139
|
|
144
140
|
describe 'PUT toggle.js' do
|
145
141
|
before do
|
146
|
-
put :toggle, id: resource.to_param, permission: "admin", format: "js"
|
142
|
+
put :toggle, params: {id: resource.to_param, permission: "admin", format: "js"}
|
147
143
|
end
|
148
144
|
|
149
145
|
it { is_expected.to respond_with(:success) }
|
@@ -152,11 +148,10 @@ describe BsmOa::AuthorizationsController, type: :controller do
|
|
152
148
|
|
153
149
|
describe 'PUT toggle.json' do
|
154
150
|
before do
|
155
|
-
put :toggle, id: resource.to_param, permission: "admin", format: "json"
|
151
|
+
put :toggle, params: {id: resource.to_param, permission: "admin", format: "json"}
|
156
152
|
end
|
157
153
|
|
158
|
-
it { is_expected.to respond_with(:
|
159
|
-
it { expect(response.body).to have_json_size(4) }
|
154
|
+
it { is_expected.to respond_with(:no_content) }
|
160
155
|
end
|
161
156
|
|
162
157
|
end
|
@@ -17,36 +17,34 @@ describe BsmOa::RolesController, type: :controller do
|
|
17
17
|
describe 'GET index.json' do
|
18
18
|
before do
|
19
19
|
resource
|
20
|
-
get :index, format: 'json'
|
20
|
+
get :index, params: {format: 'json'}
|
21
21
|
end
|
22
22
|
|
23
23
|
it { is_expected.to respond_with(:success) }
|
24
|
-
it { expect(response.body).to have_json_size(1) }
|
25
24
|
end
|
26
25
|
|
27
26
|
describe 'GET show.json' do
|
28
27
|
before do
|
29
|
-
get :show, id: resource.to_param, format: 'json'
|
28
|
+
get :show, params: {id: resource.to_param, format: 'json'}
|
30
29
|
end
|
31
30
|
|
32
31
|
it { is_expected.to respond_with(:success) }
|
33
|
-
it { expect(response.body).to have_json_size(2) }
|
34
32
|
end
|
35
33
|
|
36
34
|
describe 'POST create.json (successful)' do
|
37
35
|
before do
|
38
|
-
post :create, format: 'json',
|
36
|
+
post :create, params: {format: 'json', bsm_oa_role: build(:role).attributes }
|
39
37
|
end
|
40
38
|
|
41
|
-
it { is_expected.to respond_with(:
|
39
|
+
it { is_expected.to respond_with(:created) }
|
42
40
|
end
|
43
41
|
|
44
42
|
describe 'PUT update.json (successful)' do
|
45
43
|
before do
|
46
|
-
|
44
|
+
put :update, params: {format: 'json', id: resource.to_param, bsm_oa_role: { name: "newname"}}
|
47
45
|
end
|
48
46
|
|
49
|
-
it { is_expected.to respond_with(:
|
47
|
+
it { is_expected.to respond_with(:no_content) }
|
50
48
|
end
|
51
49
|
|
52
50
|
describe 'GET index.html' do
|
@@ -60,7 +58,7 @@ describe BsmOa::RolesController, type: :controller do
|
|
60
58
|
|
61
59
|
describe 'GET show.html' do
|
62
60
|
before do
|
63
|
-
get :show, id: resource.to_param
|
61
|
+
get :show, params: {id: resource.to_param}
|
64
62
|
end
|
65
63
|
|
66
64
|
it { is_expected.to render_template(:show) }
|
@@ -69,7 +67,7 @@ describe BsmOa::RolesController, type: :controller do
|
|
69
67
|
|
70
68
|
describe 'GET edit.html' do
|
71
69
|
before do
|
72
|
-
get :edit, id: resource.to_param
|
70
|
+
get :edit, params: {id: resource.to_param}
|
73
71
|
end
|
74
72
|
it { is_expected.to render_template(:edit) }
|
75
73
|
it { is_expected.to respond_with(:success) }
|
@@ -85,7 +83,7 @@ describe BsmOa::RolesController, type: :controller do
|
|
85
83
|
|
86
84
|
describe 'POST create.html (successful)' do
|
87
85
|
before do
|
88
|
-
post :create,
|
86
|
+
post :create, params: {bsm_oa_role: build(:role).attributes}
|
89
87
|
end
|
90
88
|
it { is_expected.to respond_with(:redirect) }
|
91
89
|
it { is_expected.to redirect_to("http://test.host/roles/#{BsmOa::Role.last.to_param}") }
|
@@ -93,7 +91,7 @@ describe BsmOa::RolesController, type: :controller do
|
|
93
91
|
|
94
92
|
describe 'POST create.html (unsuccessful)' do
|
95
93
|
before do
|
96
|
-
post :create,
|
94
|
+
post :create, params: {bsm_oa_role: resource.attributes}
|
97
95
|
end
|
98
96
|
|
99
97
|
it { is_expected.to respond_with(:success) }
|
@@ -102,7 +100,7 @@ describe BsmOa::RolesController, type: :controller do
|
|
102
100
|
|
103
101
|
describe 'PUT update.html (successful)' do
|
104
102
|
before do
|
105
|
-
post :update, id: resource.to_param,
|
103
|
+
post :update, params: {id: resource.to_param, bsm_oa_role: { name: "newname"}}
|
106
104
|
end
|
107
105
|
|
108
106
|
it { is_expected.to respond_with(:redirect) }
|
@@ -111,7 +109,7 @@ describe BsmOa::RolesController, type: :controller do
|
|
111
109
|
|
112
110
|
describe 'PUT update.html (unsuccessful)' do
|
113
111
|
before do
|
114
|
-
put :update, id: resource.to_param,
|
112
|
+
put :update, params: {id: resource.to_param, bsm_oa_role: { name: "" }}
|
115
113
|
end
|
116
114
|
|
117
115
|
it { is_expected.to respond_with(:success) }
|
@@ -120,7 +118,7 @@ describe BsmOa::RolesController, type: :controller do
|
|
120
118
|
|
121
119
|
describe 'DELETE destroy.json' do
|
122
120
|
before do
|
123
|
-
delete :destroy, format: 'json', id: resource.to_param
|
121
|
+
delete :destroy, params: {format: 'json', id: resource.to_param}
|
124
122
|
end
|
125
123
|
|
126
124
|
it { is_expected.to respond_with(:no_content) }
|
@@ -128,7 +126,7 @@ describe BsmOa::RolesController, type: :controller do
|
|
128
126
|
|
129
127
|
describe 'DELETE destroy.html' do
|
130
128
|
before do
|
131
|
-
delete :destroy, id: resource.to_param
|
129
|
+
delete :destroy, params: {id: resource.to_param}
|
132
130
|
end
|
133
131
|
|
134
132
|
it { is_expected.to respond_with(:redirect) }
|
data/spec/factories.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
|
3
|
-
factory :application, class:
|
3
|
+
factory :application, class: BsmOa::Application do
|
4
4
|
sequence(:name) { |n| "Application #{n}" }
|
5
5
|
redirect_uri 'https://app.com/callback'
|
6
6
|
permissions ['admin', 'finance', 'operations']
|