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
@@ -1 +0,0 @@
|
|
1
|
-
json.partial! 'application', application: @application
|
@@ -1 +0,0 @@
|
|
1
|
-
json.(authorization, :id, :role_id, :application_id, :permissions)
|
@@ -1 +0,0 @@
|
|
1
|
-
json.array! @authorizations, :role_id, :application_id, :permissions
|
@@ -1 +0,0 @@
|
|
1
|
-
json.partial! 'authorization', authorization: @authorization
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module BsmOa
|
2
|
-
module ApplicationMixin
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
included do
|
6
|
-
has_many :authorizations, class_name: BsmOa::Authorization, inverse_of: :application, dependent: :destroy
|
7
|
-
has_many :roles, inverse_of: :applications, class_name: BsmOa::Role, through: :authorizations, foreign_key: :role_id
|
8
|
-
|
9
|
-
serialize :permissions, Bsm::Model::Coders::JsonColumn.new(Array)
|
10
|
-
validate :must_have_simple_word_permissions
|
11
|
-
|
12
|
-
before_validation :normalize_permissions!
|
13
|
-
|
14
|
-
scope :ordered, -> { order(:name) }
|
15
|
-
end
|
16
|
-
|
17
|
-
def permissions_string=(permissions_string)
|
18
|
-
self.permissions = permissions_string.split(/\W+/)
|
19
|
-
end
|
20
|
-
|
21
|
-
def permissions_string
|
22
|
-
permissions.sort.join(' ')
|
23
|
-
end
|
24
|
-
|
25
|
-
protected
|
26
|
-
|
27
|
-
def must_have_simple_word_permissions
|
28
|
-
errors.add :permissions, :invalid if permissions.any? {|pm| pm =~ /[^a-z0-9]/ }
|
29
|
-
end
|
30
|
-
|
31
|
-
def normalize_permissions!
|
32
|
-
self.permissions = Array.wrap(permissions).reject(&:blank?).map(&:strip).map(&:downcase).uniq
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|