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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -1
  3. data/Gemfile +6 -0
  4. data/Gemfile.lock +138 -142
  5. data/app/controllers/bsm_oa/accounts_controller.rb +19 -4
  6. data/app/controllers/bsm_oa/admin_controller.rb +5 -0
  7. data/app/controllers/bsm_oa/applications_controller.rb +36 -15
  8. data/app/controllers/bsm_oa/authorizations_controller.rb +7 -6
  9. data/app/controllers/bsm_oa/base_controller.rb +5 -0
  10. data/app/controllers/bsm_oa/roles_controller.rb +3 -4
  11. data/app/views/bsm_oa/applications/_application.html.erb +2 -2
  12. data/app/views/bsm_oa/applications/_inputs.html.erb +6 -11
  13. data/app/views/bsm_oa/applications/edit.html.erb +2 -2
  14. data/app/views/bsm_oa/applications/index.html.erb +1 -1
  15. data/app/views/bsm_oa/applications/new.html.erb +2 -2
  16. data/app/views/bsm_oa/applications/show.html.erb +40 -0
  17. data/app/views/bsm_oa/authorizations/_inputs.html.erb +2 -2
  18. data/app/views/bsm_oa/authorizations/edit.html.erb +1 -1
  19. data/app/views/bsm_oa/authorizations/new.html.erb +2 -3
  20. data/app/views/bsm_oa/roles/_inputs.html.erb +3 -4
  21. data/app/views/bsm_oa/roles/edit.html.erb +1 -1
  22. data/app/views/bsm_oa/roles/new.html.erb +1 -1
  23. data/app/views/bsm_oa/roles/show.html.erb +1 -1
  24. data/bsm_oa.gemspec +6 -11
  25. data/db/migrate/20150507113313_bsm_oa_create_doorkeeper_tables.rb +1 -1
  26. data/db/migrate/20150513155732_bsm_oa_create_tables.rb +1 -1
  27. data/lib/bsm_oa.rb +0 -3
  28. data/lib/bsm_oa/application.rb +31 -0
  29. data/lib/bsm_oa/authorization.rb +8 -15
  30. data/lib/bsm_oa/config.rb +5 -0
  31. data/lib/bsm_oa/engine.rb +2 -4
  32. data/lib/bsm_oa/role.rb +1 -1
  33. data/lib/bsm_oa/routes.rb +29 -3
  34. data/lib/bsm_oa/version.rb +1 -1
  35. data/spec/controllers/bsm_oa/accounts_controller_spec.rb +15 -12
  36. data/spec/controllers/bsm_oa/applications_controller_spec.rb +22 -28
  37. data/spec/controllers/bsm_oa/authorizations_controller_spec.rb +17 -22
  38. data/spec/controllers/bsm_oa/roles_controller_spec.rb +14 -16
  39. data/spec/factories.rb +1 -1
  40. data/spec/lib/bsm_oa/{application_mixin_spec.rb → application_spec.rb} +13 -9
  41. data/spec/lib/bsm_oa/authorization_spec.rb +5 -9
  42. data/spec/lib/bsm_oa/role_spec.rb +1 -1
  43. data/spec/spec_helper.rb +18 -8
  44. metadata +22 -104
  45. data/app/views/bsm_oa/accounts/show.json.jbuilder +0 -7
  46. data/app/views/bsm_oa/applications/_application.json.jbuilder +0 -1
  47. data/app/views/bsm_oa/applications/create.json.jbuilder +0 -1
  48. data/app/views/bsm_oa/applications/index.json.jbuilder +0 -1
  49. data/app/views/bsm_oa/applications/show.json.jbuilder +0 -1
  50. data/app/views/bsm_oa/applications/update.json.jbuilder +0 -1
  51. data/app/views/bsm_oa/authorizations/_authorization.json.jbuilder +0 -1
  52. data/app/views/bsm_oa/authorizations/index.json.jbuilder +0 -1
  53. data/app/views/bsm_oa/authorizations/toggle.json.jbuilder +0 -1
  54. data/lib/bsm_oa/application_mixin.rb +0 -37
@@ -1,6 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Doorkeeper::Application, type: :model do
3
+ describe BsmOa::Application, type: :model do
4
+
5
+ it { is_expected.to be_kind_of(Doorkeeper::Application) }
6
+
7
+ it 'should a custom model name' do
8
+ expect(described_class.model_name.route_key).to eq("bsm_oa_applications")
9
+ end
4
10
 
5
11
  it { is_expected.to have_many(:authorizations).dependent(:destroy) }
6
12
  it { is_expected.to have_many(:roles).through(:authorizations) }
@@ -11,32 +17,30 @@ describe Doorkeeper::Application, type: :model do
11
17
  it { is_expected.to allow_value([val]).for(:permissions) }
12
18
  end
13
19
 
14
- ['inv&lid', 'not valid'].each do |val|
20
+ ['inv&lid', 'not-valid'].each do |val|
15
21
  it { is_expected.not_to allow_value([val]).for(:permissions) }
16
22
  end
17
23
 
18
24
  it 'should have default secret and uid attributes' do
19
- app = create(:application, secret: nil, uid: nil)
25
+ app = create :application, secret: nil, uid: nil
20
26
  expect(app.secret).to_not be_nil
21
27
  expect(app.uid).to_not be_nil
22
28
  end
23
29
 
24
30
  it 'should all secret and uid to be user set' do
25
- app = create(:application, secret: 'secr3t', uid: 'nexusU1D')
31
+ app = create :application, secret: 'secr3t', uid: 'nexusU1D'
26
32
  expect(app.secret).to eq('secr3t')
27
33
  expect(app.uid).to eq('nexusU1D')
28
34
  end
29
35
 
30
36
  it 'should normalize permissions' do
31
- app = create(:application, permissions: ['admin', 'Finance', ' employee ', ''])
37
+ app = create :application, permissions: ['admin', 'Finance', ' employee ', '']
32
38
  expect(app.permissions).to eq ['admin', 'finance', 'employee']
33
39
  end
34
40
 
35
- it 'should set and return string of permissions' do
36
- app = create(:application)
37
- app.permissions_string = 'admin, finance, employee'
41
+ it 'should allow assigning permissions as string' do
42
+ app = build :application, permissions: 'admin, finance, employee'
38
43
  expect(app.permissions).to eq ['admin', 'finance', 'employee']
39
- expect(app.permissions_string).to eq 'admin employee finance'
40
44
  end
41
45
 
42
46
  it 'should scope ordered' do
@@ -17,17 +17,13 @@ RSpec.describe BsmOa::Authorization, type: :model do
17
17
 
18
18
  it { is_expected.to serialize(:permissions) }
19
19
 
20
- it 'should set and return string of permissions' do
21
- subject = create(:authorization)
22
- subject.permissions_string = 'admin operations finance'
20
+ it 'should all to assign a string of permissions' do
21
+ subject = build(:authorization, permissions: 'admin operations finance')
23
22
  expect(subject.permissions).to eq ['admin', 'operations', 'finance']
24
- expect(subject.permissions_string).to eq 'admin finance operations'
25
23
  end
26
24
 
27
25
  it 'should normalize permissions' do
28
- subject = create(:authorization)
29
- subject.permissions = ["admin ", "Finance", "operatiOns", "unknown"]
30
- expect(subject).to be_valid
26
+ subject = create(:authorization, permissions: ["admin ", "Finance", "operatiOns", "unknown"])
31
27
  expect(subject.permissions).to eq ['admin', 'finance', 'operations']
32
28
  end
33
29
 
@@ -40,11 +36,11 @@ RSpec.describe BsmOa::Authorization, type: :model do
40
36
  let(:authorization) { create :authorization}
41
37
 
42
38
  it 'should toggle adding permissions' do
43
- authorization.toggle('finance')
39
+ authorization.toggle_permission!('finance')
44
40
  expect(authorization.reload.permissions).to eq(['admin', 'finance'])
45
41
  end
46
42
  it 'should toggle removing permissions' do
47
- authorization.toggle('admin')
43
+ authorization.toggle_permission!('admin')
48
44
  expect(authorization.reload.permissions).to eq([])
49
45
  end
50
46
  end
@@ -7,7 +7,7 @@ RSpec.describe BsmOa::Role, type: :model do
7
7
 
8
8
  it { is_expected.to validate_presence_of(:name) }
9
9
  it { is_expected.to validate_length_of(:name).is_at_most(80) }
10
- it { is_expected.to validate_uniqueness_of(:name).case_insensitive }
10
+ it { create(:role); is_expected.to validate_uniqueness_of(:name).case_insensitive }
11
11
 
12
12
  it 'should have ordered scope' do
13
13
  create(:role)
@@ -12,9 +12,6 @@ Combustion.initialize! :active_record do
12
12
  orm :active_record
13
13
  end
14
14
 
15
- SimpleForm.setup do |_|
16
- end
17
-
18
15
  end
19
16
 
20
17
  # Internal app
@@ -23,13 +20,17 @@ class User < ActiveRecord::Base
23
20
  has_many :authorizations, through: :roles, class_name: "BsmOa::Authorization"
24
21
  end
25
22
 
23
+ # ApplicationController
24
+ class ApplicationController < ActionController::Base
25
+ end
26
+
26
27
  # Load rspec
27
28
  require 'rspec/rails'
28
29
  require 'shoulda-matchers'
29
- require 'json_spec'
30
30
  require 'factory_girl'
31
31
  require 'faker'
32
32
  require 'database_cleaner'
33
+ require 'rails-controller-testing'
33
34
 
34
35
  RSpec.configure do |config|
35
36
  config.use_transactional_fixtures = true
@@ -37,9 +38,6 @@ RSpec.configure do |config|
37
38
  config.render_views
38
39
 
39
40
  config.before :suite do
40
- silence_stream(STDOUT) do
41
- ActiveRecord::Migrator.migrate(File.expand_path('../../db/migrate', __FILE__), nil)
42
- end
43
41
  FactoryGirl.find_definitions
44
42
  end
45
43
 
@@ -60,5 +58,17 @@ RSpec.configure do |config|
60
58
  end
61
59
 
62
60
  config.include FactoryGirl::Syntax::Methods
63
- config.include JsonSpec::Helpers
64
61
  end
62
+
63
+
64
+ Shoulda::Matchers.configure do |config|
65
+ config.integrate do |with|
66
+ # Choose a test framework:
67
+ with.test_framework :rspec
68
+
69
+ # Or, choose the following (which implies all of the above):
70
+ with.library :rails
71
+ end
72
+ end
73
+
74
+ Rails::Controller::Testing.install
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bsm_oa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Born
@@ -9,26 +9,20 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-18 00:00:00.000000000 Z
12
+ date: 2017-09-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">="
19
- - !ruby/object:Gem::Version
20
- version: '4.1'
21
- - - "<"
18
+ - - "~>"
22
19
  - !ruby/object:Gem::Version
23
20
  version: '5.0'
24
21
  type: :runtime
25
22
  prerelease: false
26
23
  version_requirements: !ruby/object:Gem::Requirement
27
24
  requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- version: '4.1'
31
- - - "<"
25
+ - - "~>"
32
26
  - !ruby/object:Gem::Version
33
27
  version: '5.0'
34
28
  - !ruby/object:Gem::Dependency
@@ -37,56 +31,28 @@ dependencies:
37
31
  requirements:
38
32
  - - "~>"
39
33
  - !ruby/object:Gem::Version
40
- version: 3.0.0.rc
34
+ version: 4.2.0
41
35
  type: :runtime
42
36
  prerelease: false
43
37
  version_requirements: !ruby/object:Gem::Requirement
44
38
  requirements:
45
39
  - - "~>"
46
40
  - !ruby/object:Gem::Version
47
- version: 3.0.0.rc
41
+ version: 4.2.0
48
42
  - !ruby/object:Gem::Dependency
49
43
  name: responders
50
44
  requirement: !ruby/object:Gem::Requirement
51
45
  requirements:
52
46
  - - "~>"
53
47
  - !ruby/object:Gem::Version
54
- version: '2.0'
48
+ version: '2.1'
55
49
  type: :runtime
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
52
  requirements:
59
53
  - - "~>"
60
54
  - !ruby/object:Gem::Version
61
- version: '2.0'
62
- - !ruby/object:Gem::Dependency
63
- name: jbuilder
64
- requirement: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '2.2'
69
- type: :runtime
70
- prerelease: false
71
- version_requirements: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '2.2'
76
- - !ruby/object:Gem::Dependency
77
- name: bsm-models
78
- requirement: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- type: :runtime
84
- prerelease: false
85
- version_requirements: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
55
+ version: '2.1'
90
56
  - !ruby/object:Gem::Dependency
91
57
  name: has_scope
92
58
  requirement: !ruby/object:Gem::Requirement
@@ -101,62 +67,34 @@ dependencies:
101
67
  - - "~>"
102
68
  - !ruby/object:Gem::Version
103
69
  version: '0.6'
104
- - !ruby/object:Gem::Dependency
105
- name: simple_form
106
- requirement: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '3.1'
111
- type: :runtime
112
- prerelease: false
113
- version_requirements: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '3.1'
118
- - !ruby/object:Gem::Dependency
119
- name: jquery-rails
120
- requirement: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- type: :runtime
126
- prerelease: false
127
- version_requirements: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
70
  - !ruby/object:Gem::Dependency
133
71
  name: rails
134
72
  requirement: !ruby/object:Gem::Requirement
135
73
  requirements:
136
74
  - - ">="
137
75
  - !ruby/object:Gem::Version
138
- version: '4.1'
76
+ version: '5.0'
139
77
  type: :development
140
78
  prerelease: false
141
79
  version_requirements: !ruby/object:Gem::Requirement
142
80
  requirements:
143
81
  - - ">="
144
82
  - !ruby/object:Gem::Version
145
- version: '4.1'
83
+ version: '5.0'
146
84
  - !ruby/object:Gem::Dependency
147
85
  name: combustion
148
86
  requirement: !ruby/object:Gem::Requirement
149
87
  requirements:
150
88
  - - "~>"
151
89
  - !ruby/object:Gem::Version
152
- version: 0.5.3
90
+ version: 0.7.0
153
91
  type: :development
154
92
  prerelease: false
155
93
  version_requirements: !ruby/object:Gem::Requirement
156
94
  requirements:
157
95
  - - "~>"
158
96
  - !ruby/object:Gem::Version
159
- version: 0.5.3
97
+ version: 0.7.0
160
98
  - !ruby/object:Gem::Dependency
161
99
  name: rspec-rails
162
100
  requirement: !ruby/object:Gem::Requirement
@@ -185,20 +123,6 @@ dependencies:
185
123
  - - ">="
186
124
  - !ruby/object:Gem::Version
187
125
  version: '0'
188
- - !ruby/object:Gem::Dependency
189
- name: json_spec
190
- requirement: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - ">="
193
- - !ruby/object:Gem::Version
194
- version: '0'
195
- type: :development
196
- prerelease: false
197
- version_requirements: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - ">="
200
- - !ruby/object:Gem::Version
201
- version: '0'
202
126
  - !ruby/object:Gem::Dependency
203
127
  name: faker
204
128
  requirement: !ruby/object:Gem::Requirement
@@ -214,7 +138,7 @@ dependencies:
214
138
  - !ruby/object:Gem::Version
215
139
  version: '0'
216
140
  - !ruby/object:Gem::Dependency
217
- name: shoulda-matchers
141
+ name: database_cleaner
218
142
  requirement: !ruby/object:Gem::Requirement
219
143
  requirements:
220
144
  - - ">="
@@ -228,7 +152,7 @@ dependencies:
228
152
  - !ruby/object:Gem::Version
229
153
  version: '0'
230
154
  - !ruby/object:Gem::Dependency
231
- name: database_cleaner
155
+ name: sqlite3
232
156
  requirement: !ruby/object:Gem::Requirement
233
157
  requirements:
234
158
  - - ">="
@@ -242,7 +166,7 @@ dependencies:
242
166
  - !ruby/object:Gem::Version
243
167
  version: '0'
244
168
  - !ruby/object:Gem::Dependency
245
- name: sqlite3
169
+ name: rails-controller-testing
246
170
  requirement: !ruby/object:Gem::Requirement
247
171
  requirements:
248
172
  - - ">="
@@ -267,28 +191,22 @@ files:
267
191
  - Gemfile.lock
268
192
  - Rakefile
269
193
  - app/controllers/bsm_oa/accounts_controller.rb
194
+ - app/controllers/bsm_oa/admin_controller.rb
270
195
  - app/controllers/bsm_oa/applications_controller.rb
271
196
  - app/controllers/bsm_oa/authorizations_controller.rb
197
+ - app/controllers/bsm_oa/base_controller.rb
272
198
  - app/controllers/bsm_oa/roles_controller.rb
273
- - app/views/bsm_oa/accounts/show.json.jbuilder
274
199
  - app/views/bsm_oa/applications/_application.html.erb
275
- - app/views/bsm_oa/applications/_application.json.jbuilder
276
200
  - app/views/bsm_oa/applications/_inputs.html.erb
277
- - app/views/bsm_oa/applications/create.json.jbuilder
278
201
  - app/views/bsm_oa/applications/edit.html.erb
279
202
  - app/views/bsm_oa/applications/index.html.erb
280
- - app/views/bsm_oa/applications/index.json.jbuilder
281
203
  - app/views/bsm_oa/applications/new.html.erb
282
- - app/views/bsm_oa/applications/show.json.jbuilder
283
- - app/views/bsm_oa/applications/update.json.jbuilder
284
- - app/views/bsm_oa/authorizations/_authorization.json.jbuilder
204
+ - app/views/bsm_oa/applications/show.html.erb
285
205
  - app/views/bsm_oa/authorizations/_inputs.html.erb
286
206
  - app/views/bsm_oa/authorizations/edit.html.erb
287
207
  - app/views/bsm_oa/authorizations/index.html.erb
288
- - app/views/bsm_oa/authorizations/index.json.jbuilder
289
208
  - app/views/bsm_oa/authorizations/new.html.erb
290
209
  - app/views/bsm_oa/authorizations/toggle.js.erb
291
- - app/views/bsm_oa/authorizations/toggle.json.jbuilder
292
210
  - app/views/bsm_oa/roles/_authorization.html.erb
293
211
  - app/views/bsm_oa/roles/_inputs.html.erb
294
212
  - app/views/bsm_oa/roles/_role.html.erb
@@ -306,7 +224,7 @@ files:
306
224
  - db/migrate/20150507113313_bsm_oa_create_doorkeeper_tables.rb
307
225
  - db/migrate/20150513155732_bsm_oa_create_tables.rb
308
226
  - lib/bsm_oa.rb
309
- - lib/bsm_oa/application_mixin.rb
227
+ - lib/bsm_oa/application.rb
310
228
  - lib/bsm_oa/authorization.rb
311
229
  - lib/bsm_oa/config.rb
312
230
  - lib/bsm_oa/engine.rb
@@ -324,7 +242,7 @@ files:
324
242
  - spec/internal/db/schema.rb
325
243
  - spec/internal/log/.gitignore
326
244
  - spec/internal/public/favicon.ico
327
- - spec/lib/bsm_oa/application_mixin_spec.rb
245
+ - spec/lib/bsm_oa/application_spec.rb
328
246
  - spec/lib/bsm_oa/authorization_spec.rb
329
247
  - spec/lib/bsm_oa/config_spec.rb
330
248
  - spec/lib/bsm_oa/role_spec.rb
@@ -349,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
349
267
  version: '0'
350
268
  requirements: []
351
269
  rubyforge_project:
352
- rubygems_version: 2.4.7
270
+ rubygems_version: 2.6.11
353
271
  signing_key:
354
272
  specification_version: 4
355
273
  summary: Rails Open Authority engine
@@ -365,7 +283,7 @@ test_files:
365
283
  - spec/internal/db/schema.rb
366
284
  - spec/internal/log/.gitignore
367
285
  - spec/internal/public/favicon.ico
368
- - spec/lib/bsm_oa/application_mixin_spec.rb
286
+ - spec/lib/bsm_oa/application_spec.rb
369
287
  - spec/lib/bsm_oa/authorization_spec.rb
370
288
  - spec/lib/bsm_oa/config_spec.rb
371
289
  - spec/lib/bsm_oa/role_spec.rb
@@ -1,7 +0,0 @@
1
- json.(@account, *BsmOa.config.user_attrs)
2
-
3
- json.authorizations @account.authorizations.includes(:application) do |auth|
4
- json.uid auth.application.uid
5
- json.permissions auth.permissions
6
- end if @account.respond_to?(:authorizations)
7
-
@@ -1 +0,0 @@
1
- json.(application, :id, :name, :uid, :secret, :redirect_uri, :scopes)
@@ -1 +0,0 @@
1
- json.partial! 'application', application: @application
@@ -1 +0,0 @@
1
- json.array! @applications, :id, :name
@@ -1 +0,0 @@
1
- json.partial! 'application', application: @application