bsm_oa 0.3.1 → 0.4.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.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5025b6ecca24e19622010e73f34aeb51ab6c41c
4
- data.tar.gz: 509fddabc2da4dc37aac6fe107af71dd43dd9885
3
+ metadata.gz: ddc376432fcee2544323684d8630c60d07850f55
4
+ data.tar.gz: 96184f746bb222c599a9ac3aba2962a544ca8f5a
5
5
  SHA512:
6
- metadata.gz: 2813cf35613dca6b1693216d3ca2f3f304eb28003e92f162d567657e7f6afc1033fa9dc8a33459b1e5bb377168e277ff91e6dfb779ed5e903866fc51e017df34
7
- data.tar.gz: d497df0bc2375359c9cbcb49edda1034447350370c2bd626d0228d23232071cb20958de605b765776903f2159c6ed8a406ae4c701609722a9b2b6c0c4ade62e4
6
+ metadata.gz: 16dafd2b6d854c321d0d4da2412bd35d8d9c6eacd84610270598b750440362a901870836b593ed229733bfc004c5f8495e6faedae690983204e7f7ccaf068f9a
7
+ data.tar.gz: 8eb7d9eedae1e024315fe2bb9b723414a94b3500e6ca3795abbcb16224e9879755a8f0c89685abce7576a5d42d83a7bb2720b738c18b60ea71ba7d70ce9d8917
@@ -2,4 +2,3 @@ language: ruby
2
2
  rvm:
3
3
  - 2.2.2
4
4
  - 2.1.3
5
- - 1.9.3
data/Gemfile CHANGED
@@ -1,3 +1,9 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ # TODO! shoulda matcher support for rails5 is on a specific branch
6
+ # I needed to extract the dependency from the gemspec into the Gemfile to ensure it would include the correct one
7
+ group :test do
8
+ gem 'shoulda-matchers', git: 'https://github.com/thoughtbot/shoulda-matchers.git', branch: 'rails-5'
9
+ end
@@ -1,180 +1,176 @@
1
+ GIT
2
+ remote: https://github.com/thoughtbot/shoulda-matchers.git
3
+ revision: 4b160bd19ecca7f97d7ac22dccd5fde9b0da5a9f
4
+ branch: rails-5
5
+ specs:
6
+ shoulda-matchers (3.1.2)
7
+ activesupport (>= 4.2.0)
8
+
1
9
  PATH
2
10
  remote: .
3
11
  specs:
4
- bsm_oa (0.3.1)
5
- bsm-models
6
- doorkeeper (~> 3.0.0.rc)
12
+ bsm_oa (0.4.0)
13
+ doorkeeper (~> 4.2.0)
7
14
  has_scope (~> 0.6)
8
- jbuilder (~> 2.2)
9
- jquery-rails
10
- railties (>= 4.1, < 5.0)
11
- responders (~> 2.0)
12
- simple_form (~> 3.1)
15
+ railties (~> 5.0)
16
+ responders (~> 2.1)
13
17
 
14
18
  GEM
15
19
  remote: https://rubygems.org/
16
20
  specs:
17
- abstract (1.0.0)
18
- actionmailer (4.2.2)
19
- actionpack (= 4.2.2)
20
- actionview (= 4.2.2)
21
- activejob (= 4.2.2)
21
+ actioncable (5.1.4)
22
+ actionpack (= 5.1.4)
23
+ nio4r (~> 2.0)
24
+ websocket-driver (~> 0.6.1)
25
+ actionmailer (5.1.4)
26
+ actionpack (= 5.1.4)
27
+ actionview (= 5.1.4)
28
+ activejob (= 5.1.4)
22
29
  mail (~> 2.5, >= 2.5.4)
23
- rails-dom-testing (~> 1.0, >= 1.0.5)
24
- actionpack (4.2.2)
25
- actionview (= 4.2.2)
26
- activesupport (= 4.2.2)
27
- rack (~> 1.6)
28
- rack-test (~> 0.6.2)
29
- rails-dom-testing (~> 1.0, >= 1.0.5)
30
- rails-html-sanitizer (~> 1.0, >= 1.0.1)
31
- actionview (4.2.2)
32
- activesupport (= 4.2.2)
33
- builder (~> 3.1)
34
- erubis (~> 2.7.0)
35
- rails-dom-testing (~> 1.0, >= 1.0.5)
36
- rails-html-sanitizer (~> 1.0, >= 1.0.1)
37
- activejob (4.2.2)
38
- activesupport (= 4.2.2)
39
- globalid (>= 0.3.0)
40
- activemodel (4.2.2)
41
- activesupport (= 4.2.2)
30
+ rails-dom-testing (~> 2.0)
31
+ actionpack (5.1.4)
32
+ actionview (= 5.1.4)
33
+ activesupport (= 5.1.4)
34
+ rack (~> 2.0)
35
+ rack-test (>= 0.6.3)
36
+ rails-dom-testing (~> 2.0)
37
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
38
+ actionview (5.1.4)
39
+ activesupport (= 5.1.4)
42
40
  builder (~> 3.1)
43
- activerecord (4.2.2)
44
- activemodel (= 4.2.2)
45
- activesupport (= 4.2.2)
46
- arel (~> 6.0)
47
- activesupport (4.2.2)
41
+ erubi (~> 1.4)
42
+ rails-dom-testing (~> 2.0)
43
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
44
+ activejob (5.1.4)
45
+ activesupport (= 5.1.4)
46
+ globalid (>= 0.3.6)
47
+ activemodel (5.1.4)
48
+ activesupport (= 5.1.4)
49
+ activerecord (5.1.4)
50
+ activemodel (= 5.1.4)
51
+ activesupport (= 5.1.4)
52
+ arel (~> 8.0)
53
+ activesupport (5.1.4)
54
+ concurrent-ruby (~> 1.0, >= 1.0.2)
48
55
  i18n (~> 0.7)
49
- json (~> 1.7, >= 1.7.7)
50
56
  minitest (~> 5.1)
51
- thread_safe (~> 0.3, >= 0.3.4)
52
57
  tzinfo (~> 1.1)
53
- arel (6.0.0)
54
- bsm-models (0.8.2)
55
- abstract
56
- activerecord (>= 4.1.0, < 5.0.0)
57
- railties (>= 4.1.0, < 5.0.0)
58
- builder (3.2.2)
59
- combustion (0.5.3)
58
+ arel (8.0.0)
59
+ builder (3.2.3)
60
+ combustion (0.7.0)
60
61
  activesupport (>= 3.0.0)
61
62
  railties (>= 3.0.0)
62
63
  thor (>= 0.14.6)
63
- database_cleaner (1.4.1)
64
- diff-lcs (1.2.5)
65
- doorkeeper (3.0.0.rc1)
66
- railties (>= 3.2)
67
- erubis (2.7.0)
68
- factory_girl (4.5.0)
64
+ concurrent-ruby (1.0.5)
65
+ database_cleaner (1.6.1)
66
+ diff-lcs (1.3)
67
+ doorkeeper (4.2.6)
68
+ railties (>= 4.2)
69
+ erubi (1.6.1)
70
+ factory_girl (4.8.0)
69
71
  activesupport (>= 3.0.0)
70
- faker (1.4.3)
72
+ faker (1.8.4)
71
73
  i18n (~> 0.5)
72
- globalid (0.3.5)
73
- activesupport (>= 4.1.0)
74
- has_scope (0.6.0)
75
- actionpack (>= 3.2, < 5)
76
- activesupport (>= 3.2, < 5)
77
- i18n (0.7.0)
78
- jbuilder (2.3.0)
79
- activesupport (>= 3.0.0, < 5)
80
- multi_json (~> 1.2)
81
- jquery-rails (4.0.4)
82
- rails-dom-testing (~> 1.0)
83
- railties (>= 4.2.0)
84
- thor (>= 0.14, < 2.0)
85
- json (1.8.3)
86
- json_spec (1.1.4)
87
- multi_json (~> 1.0)
88
- rspec (>= 2.0, < 4.0)
89
- loofah (2.0.2)
74
+ globalid (0.4.0)
75
+ activesupport (>= 4.2.0)
76
+ has_scope (0.7.1)
77
+ actionpack (>= 4.1, < 5.2)
78
+ activesupport (>= 4.1, < 5.2)
79
+ i18n (0.8.6)
80
+ loofah (2.0.3)
90
81
  nokogiri (>= 1.5.9)
91
- mail (2.6.3)
92
- mime-types (>= 1.16, < 3)
93
- mime-types (2.6.1)
94
- mini_portile (0.6.2)
95
- minitest (5.7.0)
96
- multi_json (1.11.1)
97
- nokogiri (1.6.6.2)
98
- mini_portile (~> 0.6.0)
99
- rack (1.6.2)
100
- rack-test (0.6.3)
101
- rack (>= 1.0)
102
- rails (4.2.2)
103
- actionmailer (= 4.2.2)
104
- actionpack (= 4.2.2)
105
- actionview (= 4.2.2)
106
- activejob (= 4.2.2)
107
- activemodel (= 4.2.2)
108
- activerecord (= 4.2.2)
109
- activesupport (= 4.2.2)
110
- bundler (>= 1.3.0, < 2.0)
111
- railties (= 4.2.2)
112
- sprockets-rails
113
- rails-deprecated_sanitizer (1.0.3)
114
- activesupport (>= 4.2.0.alpha)
115
- rails-dom-testing (1.0.6)
116
- activesupport (>= 4.2.0.beta, < 5.0)
117
- nokogiri (~> 1.6.0)
118
- rails-deprecated_sanitizer (>= 1.0.1)
119
- rails-html-sanitizer (1.0.2)
82
+ mail (2.6.6)
83
+ mime-types (>= 1.16, < 4)
84
+ method_source (0.8.2)
85
+ mime-types (3.1)
86
+ mime-types-data (~> 3.2015)
87
+ mime-types-data (3.2016.0521)
88
+ mini_portile2 (2.2.0)
89
+ minitest (5.10.3)
90
+ nio4r (2.1.0)
91
+ nokogiri (1.8.0)
92
+ mini_portile2 (~> 2.2.0)
93
+ rack (2.0.3)
94
+ rack-test (0.7.0)
95
+ rack (>= 1.0, < 3)
96
+ rails (5.1.4)
97
+ actioncable (= 5.1.4)
98
+ actionmailer (= 5.1.4)
99
+ actionpack (= 5.1.4)
100
+ actionview (= 5.1.4)
101
+ activejob (= 5.1.4)
102
+ activemodel (= 5.1.4)
103
+ activerecord (= 5.1.4)
104
+ activesupport (= 5.1.4)
105
+ bundler (>= 1.3.0)
106
+ railties (= 5.1.4)
107
+ sprockets-rails (>= 2.0.0)
108
+ rails-controller-testing (1.0.2)
109
+ actionpack (~> 5.x, >= 5.0.1)
110
+ actionview (~> 5.x, >= 5.0.1)
111
+ activesupport (~> 5.x)
112
+ rails-dom-testing (2.0.3)
113
+ activesupport (>= 4.2.0)
114
+ nokogiri (>= 1.6)
115
+ rails-html-sanitizer (1.0.3)
120
116
  loofah (~> 2.0)
121
- railties (4.2.2)
122
- actionpack (= 4.2.2)
123
- activesupport (= 4.2.2)
117
+ railties (5.1.4)
118
+ actionpack (= 5.1.4)
119
+ activesupport (= 5.1.4)
120
+ method_source
124
121
  rake (>= 0.8.7)
125
122
  thor (>= 0.18.1, < 2.0)
126
- rake (10.4.2)
127
- responders (2.1.0)
128
- railties (>= 4.2.0, < 5)
129
- rspec (3.3.0)
130
- rspec-core (~> 3.3.0)
131
- rspec-expectations (~> 3.3.0)
132
- rspec-mocks (~> 3.3.0)
133
- rspec-core (3.3.1)
134
- rspec-support (~> 3.3.0)
135
- rspec-expectations (3.3.0)
123
+ rake (12.1.0)
124
+ responders (2.4.0)
125
+ actionpack (>= 4.2.0, < 5.3)
126
+ railties (>= 4.2.0, < 5.3)
127
+ rspec-core (3.6.0)
128
+ rspec-support (~> 3.6.0)
129
+ rspec-expectations (3.6.0)
136
130
  diff-lcs (>= 1.2.0, < 2.0)
137
- rspec-support (~> 3.3.0)
138
- rspec-mocks (3.3.0)
131
+ rspec-support (~> 3.6.0)
132
+ rspec-mocks (3.6.0)
139
133
  diff-lcs (>= 1.2.0, < 2.0)
140
- rspec-support (~> 3.3.0)
141
- rspec-rails (3.3.2)
142
- actionpack (>= 3.0, < 4.3)
143
- activesupport (>= 3.0, < 4.3)
144
- railties (>= 3.0, < 4.3)
145
- rspec-core (~> 3.3.0)
146
- rspec-expectations (~> 3.3.0)
147
- rspec-mocks (~> 3.3.0)
148
- rspec-support (~> 3.3.0)
149
- rspec-support (3.3.0)
150
- shoulda-matchers (2.8.0)
151
- activesupport (>= 3.0.0)
152
- simple_form (3.1.0)
153
- actionpack (~> 4.0)
154
- activemodel (~> 4.0)
155
- sprockets (3.2.0)
156
- rack (~> 1.0)
157
- sprockets-rails (2.3.1)
134
+ rspec-support (~> 3.6.0)
135
+ rspec-rails (3.6.1)
158
136
  actionpack (>= 3.0)
159
137
  activesupport (>= 3.0)
160
- sprockets (>= 2.8, < 4.0)
161
- sqlite3 (1.3.10)
162
- thor (0.19.1)
163
- thread_safe (0.3.5)
164
- tzinfo (1.2.2)
138
+ railties (>= 3.0)
139
+ rspec-core (~> 3.6.0)
140
+ rspec-expectations (~> 3.6.0)
141
+ rspec-mocks (~> 3.6.0)
142
+ rspec-support (~> 3.6.0)
143
+ rspec-support (3.6.0)
144
+ sprockets (3.7.1)
145
+ concurrent-ruby (~> 1.0)
146
+ rack (> 1, < 3)
147
+ sprockets-rails (3.2.1)
148
+ actionpack (>= 4.0)
149
+ activesupport (>= 4.0)
150
+ sprockets (>= 3.0.0)
151
+ sqlite3 (1.3.13)
152
+ thor (0.20.0)
153
+ thread_safe (0.3.6)
154
+ tzinfo (1.2.3)
165
155
  thread_safe (~> 0.1)
156
+ websocket-driver (0.6.5)
157
+ websocket-extensions (>= 0.1.0)
158
+ websocket-extensions (0.1.2)
166
159
 
167
160
  PLATFORMS
168
161
  ruby
169
162
 
170
163
  DEPENDENCIES
171
164
  bsm_oa!
172
- combustion (~> 0.5.3)
165
+ combustion (~> 0.7.0)
173
166
  database_cleaner
174
167
  factory_girl
175
168
  faker
176
- json_spec
177
- rails (>= 4.1)
169
+ rails (>= 5.0)
170
+ rails-controller-testing
178
171
  rspec-rails
179
- shoulda-matchers
172
+ shoulda-matchers!
180
173
  sqlite3
174
+
175
+ BUNDLED WITH
176
+ 1.14.5
@@ -1,12 +1,27 @@
1
1
  module BsmOa
2
- class AccountsController < Doorkeeper::ApplicationController
2
+ class AccountsController < ActionController::Metal
3
+ include AbstractController::Callbacks
4
+ include ActionController::Head
5
+ include Doorkeeper::Rails::Helpers
6
+
3
7
  before_action :doorkeeper_authorize!
4
- respond_to :json
5
8
 
6
9
  # GET /me.json
7
10
  def show
8
- @account = BsmOa.config.user_class.find doorkeeper_token.try(:resource_owner_id)
9
- respond_with @account
11
+ self.content_type = Mime[:json]
12
+ self.response_body = account.respond_to?(:oa_json) ? account.oa_json : account.to_json
10
13
  end
14
+
15
+ private
16
+
17
+ def valid_doorkeeper_token?
18
+ !!account && super
19
+ end
20
+
21
+ def account
22
+ return @_account if defined?(@_account)
23
+ @_account = BsmOa.config.user_class.find_by_id doorkeeper_token.try(:resource_owner_id)
24
+ end
25
+
11
26
  end
12
27
  end
@@ -0,0 +1,5 @@
1
+ module BsmOa
2
+ class AdminController < BaseController
3
+ before_action :authenticate_admin!
4
+ end
5
+ end
@@ -1,34 +1,55 @@
1
1
  module BsmOa
2
- class ApplicationsController < Doorkeeper::ApplicationsController
3
- respond_to :html, :json
4
- before_filter :redirect_to_index_on_html, only: [:show]
2
+ class ApplicationsController < AdminController
3
+ respond_to :html
4
+ respond_to :json, except: [:new, :edit]
5
+ has_scope :ordered, default: true, only: [:index]
6
+
7
+ def index
8
+ @applications = apply_scopes(resource_scope)
9
+ respond_with @applications
10
+ end
11
+
12
+ def show
13
+ respond_with resource
14
+ end
15
+
16
+ def new
17
+ @application = resource_scope.new
18
+ respond_with @application
19
+ end
20
+
21
+ def edit
22
+ respond_with resource
23
+ end
5
24
 
6
25
  def create
7
- @application = Doorkeeper::Application.create(application_params)
8
- location = oauth_application_path(@application) if @application.persisted?
9
- respond_with @application, location: location
26
+ @application = resource_scope.create permitted_params
27
+ respond_with @application
10
28
  end
11
29
 
12
30
  def update
13
- @application.update(application_params)
14
- respond_with @application, location: oauth_application_path(@application)
31
+ resource.update(permitted_params)
32
+ respond_with resource
15
33
  end
16
34
 
17
35
  def destroy
18
- respond_with @application, location: oauth_applications_path
36
+ resource.destroy
37
+ respond_with resource, location: bsm_oa_applications_path
19
38
  end
20
39
 
21
40
  protected
22
41
 
23
- def application_params
24
- params.require(:doorkeeper_application).permit(:name, :redirect_uri, :permissions, :permissions_string, :uid, :secret)
42
+ def resource
43
+ @application ||= resource_scope.find params[:id]
25
44
  end
26
45
 
27
- def redirect_to_index_on_html
28
- return unless request.format.html?
46
+ # @return [ActiveRecord::Relation]
47
+ def resource_scope
48
+ BsmOa::Application.all
49
+ end
29
50
 
30
- flash.keep
31
- redirect_to oauth_applications_path
51
+ def permitted_params
52
+ params.require(:bsm_oa_application).permit(:name, :redirect_uri, :permissions, :uid, :secret)
32
53
  end
33
54
 
34
55
  end