monarchy 2.0.5 → 2.0.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06424c3fd8fd9422b232967b61867089bc1411e4
4
- data.tar.gz: 2d1fea1e4a50bbb1f64a02c156f16ee980bae7ea
3
+ metadata.gz: addca284a9a12f9d545fbf43ebf3de15908a6618
4
+ data.tar.gz: ba69a2d1eb4a11dff1a6ad294c9d2469b653d5f8
5
5
  SHA512:
6
- metadata.gz: fdc98fcda0e37b21191488d55daa1380698a89cb0c55cf147feeae57965862b47fa0f6214aa8ae33c986fa080a9f3c23a6364b8ba360a54fcbef46f215ae6e69
7
- data.tar.gz: 63eb3b30a58961cf0561f866aea7c9812db0f14a12cb914c3b04ef9900250d25b47ad8ace94e5164c0c0d4583bfcdebfde5b6c43f089d1270542219f43796e9b
6
+ metadata.gz: b0b5d0651fc8ea7b1bcf4e77bb532304fac7a3d695093510fcf11e2115bcc98ea2cc4a22b05bf1df6796a204bccaa63b74b21b6365f3804762f87fd6d15d0102
7
+ data.tar.gz: 7184060eb920b6323dfbe85ffac7e2f8725907c458be8f9691c6b305bf5443c4e74ec686bb101b7accd1bcfd4eb1a715fdc28402eeee2c6fed13175897bde2a8
@@ -1 +1 @@
1
- future-release=2.0.5
1
+ future-release=2.0.6
data/.rubocop.yml CHANGED
@@ -9,6 +9,8 @@ Documentation:
9
9
  Enabled: false
10
10
  Metrics/LineLength:
11
11
  Max: 125
12
+ Metrics/ModuleLength:
13
+ Max: 150
12
14
  Style/CaseIndentation:
13
15
  Enabled: false
14
16
  Style/StructInheritance:
data/.travis.yml CHANGED
@@ -1,4 +1,9 @@
1
+ addons:
2
+ code_climate:
3
+ repo_token: 60b8a9fc7e8d659c7dd22ed8912651c35b3ca5eebf1c23d5470308e6a802abbd
1
4
  language: ruby
2
5
  rvm:
3
6
  - 2.3.1
4
7
  before_install: gem install bundler -v 1.12
8
+ after_success:
9
+ - bundle exec codeclimate-test-reporter
data/CHANGELOG.md CHANGED
@@ -1,7 +1,14 @@
1
1
  # Change Log
2
2
 
3
- ## [2.0.5](https://github.com/Exelord/Monarchy/tree/2.0.5) (2016-11-10)
4
- [Full Changelog](https://github.com/Exelord/Monarchy/compare/v2.0.4...2.0.5)
3
+ ## [2.0.6](https://github.com/Exelord/Monarchy/tree/2.0.6) (2016-11-29)
4
+ [Full Changelog](https://github.com/Exelord/Monarchy/compare/v2.0.5...2.0.6)
5
+
6
+ **Fixed bugs:**
7
+
8
+ - Fix roles order [\#63](https://github.com/Exelord/Monarchy/pull/63) ([Exelord](https://github.com/Exelord))
9
+
10
+ ## [v2.0.5](https://github.com/Exelord/Monarchy/tree/v2.0.5) (2016-11-10)
11
+ [Full Changelog](https://github.com/Exelord/Monarchy/compare/v2.0.4...v2.0.5)
5
12
 
6
13
  **Merged pull requests:**
7
14
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- monarchy (2.0.5)
4
+ monarchy (2.0.6)
5
5
  active_record_union (= 1.2.0)
6
6
  activerecord (>= 4.2.7.1)
7
7
  closure_tree (= 6.2.0)
data/README.md CHANGED
@@ -12,6 +12,9 @@
12
12
  <a href="https://codeclimate.com/github/Exelord/Monarchy">
13
13
  <img src="https://codeclimate.com/github/Exelord/Monarchy/badges/gpa.svg">
14
14
  </a>
15
+ <a href="https://codeclimate.com/github/Exelord/Monarchy/coverage">
16
+ <img src="https://codeclimate.com/github/Exelord/Monarchy/badges/coverage.svg" />
17
+ </a>
15
18
  </p>
16
19
 
17
20
  Monarchy is a ruby gem offering a complete solution to manage an access in your web application.
@@ -33,19 +36,29 @@ manager_role = Monarchy.role_class.create(name: :manager, level: 4, inherited_ro
33
36
  project1 = Project.create()
34
37
  project2 = Project.create(parent: project1)
35
38
  project3 = Project.create(parent: project2)
36
- project4 = Project.create()
39
+ project4 = Project.create(parent: project1)
37
40
 
38
41
  # Grant user
39
42
  user.grant(:manager, project2)
40
43
 
41
44
  # Accessible projects
42
- Project.accessible_for(user) # returns [Project1, Project2, Project3]
45
+ Project.accessible_for(user) # returns [project1, project2, project3]
43
46
 
44
47
  # User inherited roles
45
48
  user.roles_for(project1) # returns a default role eg. [guest_role]
46
49
  user.roles_for(project2) # returns [manager_role]
47
50
  user.roles_for(project3) # returns [admin_role]
48
51
  user.roles_for(project4) # returns empty array []
52
+
53
+ # Graphical visualization
54
+
55
+ # project1 (default role, eg. guest)
56
+ # |
57
+ # |
58
+ # (granted as manager) project2 project4 (no access)
59
+ # |
60
+ # |
61
+ # project3 (admin | inherited role from manager_role)
49
62
  ```
50
63
 
51
64
  ## Requirements
@@ -55,10 +55,10 @@ module Monarchy
55
55
  accessible_roles = if inheritnce
56
56
  resource_and_inheritance_roles(resource)
57
57
  else
58
- resource_roles(resource).order('level desc')
58
+ resource_roles(resource)
59
59
  end
60
60
 
61
- return accessible_roles if accessible_roles.present?
61
+ return accessible_roles.order(level: :desc, name: :asc) if accessible_roles.present?
62
62
  inheritnce ? descendant_role(resource) : Monarchy.role_class.none
63
63
  end
64
64
 
@@ -87,7 +87,12 @@ module Monarchy
87
87
  def descendant_role(resource)
88
88
  descendants = resource.hierarchy.descendants
89
89
  children_access = members_for(descendants).present?
90
- children_access ? Monarchy.role_class.where(id: inherited_default_role) : Monarchy.role_class.none
90
+
91
+ if children_access
92
+ Monarchy.role_class.where(id: inherited_default_role).order(level: :desc, name: :asc)
93
+ else
94
+ Monarchy.role_class.none
95
+ end
91
96
  end
92
97
 
93
98
  def revoking_role(role_name, resource, strategy = nil)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Monarchy
3
- VERSION = '2.0.5'
3
+ VERSION = '2.0.6'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monarchy
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Exelord
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-10 00:00:00.000000000 Z
11
+ date: 2016-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord