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 +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
-