Skip to content
This repository has been archived by the owner on Jan 4, 2021. It is now read-only.

Tt 4960 role in title order #14

Merged
merged 4 commits into from
Jan 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ pkg
coverage
Gemfile.lock
tmp
vendor
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ rvm:
- 2.3
- 2.4
- 2.5
- 2.6
script: "bundle exec rake spec"
gemfile:
- gemfiles/rails4.gemfile
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ This changelog adheres to [Keep a CHANGELOG](http://keepachangelog.com/).

## Unreleased

- [TT-4960] ByGroup will now return a hash sorted by role name

## 0.4.0

### Improved
Expand Down
4 changes: 2 additions & 2 deletions lib/right_on/by_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ def initialize
end

def by_groups
yaml_rights.each_pair.with_object({}) do |(group, right_names), hash|
yaml_rights.each_pair.with_object({}) { |(group, right_names), hash|
hash[group] = right_names
.flat_map { |right_name| right_name_to_rights(right_name) }
end
}.sort.to_h
end

private
Expand Down
9 changes: 8 additions & 1 deletion spec/by_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@
describe RightOn::ByGroup do
let(:rights) { Bootstrap.various_rights_with_actions }

before do
rights
end

it 'should be sorted' do
expect(RightOn::ByGroup.rights.keys).to eq ['admin', 'general']
end

it 'should identify correct groups' do
rights # load rights
expect(RightOn::ByGroup.rights).to eq(
'general' => [
rights[:models],
Expand Down