hydra-role-management 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +68 -0
- data/.rubocop.yml +50 -0
- data/CONTRIBUTING.md +22 -20
- data/Gemfile +3 -3
- data/README.md +33 -1
- data/Rakefile +14 -17
- data/SUPPORT.md +6 -0
- data/app/controllers/concerns/hydra/role_management/roles_behavior.rb +15 -16
- data/app/controllers/concerns/hydra/role_management/user_roles_behavior.rb +9 -8
- data/app/controllers/roles_controller.rb +2 -1
- data/app/controllers/user_roles_controller.rb +2 -2
- data/app/models/concerns/hydra/role_management/legacy_attribute_handling.rb +2 -0
- data/app/models/concerns/hydra/role_management/user_roles.rb +5 -4
- data/app/models/role.rb +8 -5
- data/app/views/roles/edit.html.erb +1 -1
- data/config/routes.rb +2 -2
- data/hydra-role-management.gemspec +19 -14
- data/lib/generators/roles/roles_generator.rb +30 -32
- data/lib/generators/roles/templates/hydra_role_management_rails3.rb +2 -1
- data/lib/generators/roles/templates/migrations/user_roles.rb +3 -2
- data/lib/hydra-role-management.rb +9 -3
- data/lib/hydra/role_management.rb +4 -2
- data/lib/hydra/role_management/version.rb +2 -1
- data/spec/controllers/roles_controller_spec.rb +27 -30
- data/spec/controllers/user_roles_controller_spec.rb +15 -13
- data/spec/lib/user_roles_spec.rb +21 -21
- data/spec/models/role_spec.rb +22 -20
- data/spec/routing/role_management_routes_spec.rb +29 -44
- data/spec/spec_helper.rb +4 -2
- data/spec/test_app_templates/app/models/sample.rb +7 -8
- data/spec/test_app_templates/app/models/solr_document.rb +2 -2
- data/spec/test_app_templates/config/initializers/hydra_config.rb +6 -6
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +6 -5
- metadata +88 -17
- data/.travis.yml +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 43d32b791bfcce71d8fb6950ac904b7cd3cf42d5374acdc1ff836844e24195cf
|
4
|
+
data.tar.gz: aad28432d32a9ada60bfdaec8e7233cf75c5e259c04e219a088a6e6e9ff819cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0de2f191b4bded67f56f0b1e044d451e5f2508889ddc36c84302410ace557a5c0a03ef852236af590ab74f54faed6ef70dba65040aee1e3eef6b27bce6c9412c
|
7
|
+
data.tar.gz: 1d6d6f6591d87c94e7168eb1922eb667868dcc5a2f13e6005e5f704013d837face247f39afe3556689b185d96bab6b0da3b7f94fdf7bd509ed2489f9a8551c47
|
@@ -0,0 +1,68 @@
|
|
1
|
+
---
|
2
|
+
version: 2.1
|
3
|
+
orbs:
|
4
|
+
samvera: samvera/circleci-orb@0
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
parameters:
|
8
|
+
ruby_version:
|
9
|
+
type: string
|
10
|
+
bundler_version:
|
11
|
+
type: string
|
12
|
+
default: 1.17.3
|
13
|
+
rails_version:
|
14
|
+
type: string
|
15
|
+
executor:
|
16
|
+
name: 'samvera/ruby_fcrepo_solr'
|
17
|
+
ruby_version: << parameters.ruby_version >>
|
18
|
+
environment:
|
19
|
+
RAILS_VERSION: << parameters.rails_version >>
|
20
|
+
NOKOGIRI_USE_SYSTEM_LIBRARIES: true
|
21
|
+
ENGINE_CART_RAILS_OPTIONS: --skip-git --skip-bundle --skip-listen --skip-spring --skip-yarn --skip-keeps --skip-action-cable --skip-coffee --skip-puma --skip-test
|
22
|
+
steps:
|
23
|
+
- samvera/cached_checkout
|
24
|
+
- samvera/bundle_for_gem:
|
25
|
+
ruby_version: << parameters.ruby_version >>
|
26
|
+
bundler_version: << parameters.bundler_version >>
|
27
|
+
project: hydra-role-management
|
28
|
+
- samvera/rubocop
|
29
|
+
- samvera/engine_cart_generate:
|
30
|
+
cache_key: v1-internal-test-app-{{ checksum "hydra-role-management.gemspec" }}-{{ checksum "spec/test_app_templates/lib/generators/test_app_generator.rb" }}-{{ checksum "lib/generators/roles/roles_generator.rb" }}-<< parameters.rails_version >>-<< parameters.ruby_version >>
|
31
|
+
- samvera/bundle_for_gem:
|
32
|
+
ruby_version: << parameters.ruby_version >>
|
33
|
+
bundler_version: << parameters.bundler_version >>
|
34
|
+
project: hydra-role-management
|
35
|
+
- samvera/parallel_rspec
|
36
|
+
- persist_to_workspace:
|
37
|
+
root: ~/
|
38
|
+
paths:
|
39
|
+
- project/*
|
40
|
+
- project/**/*
|
41
|
+
|
42
|
+
workflows:
|
43
|
+
ci:
|
44
|
+
jobs:
|
45
|
+
- test:
|
46
|
+
name: ruby2-6_rails5-2
|
47
|
+
ruby_version: 2.6.3
|
48
|
+
rails_version: 5.2.3
|
49
|
+
- test:
|
50
|
+
name: ruby2-5_rails5-2
|
51
|
+
ruby_version: 2.5.5
|
52
|
+
rails_version: 5.2.3
|
53
|
+
- test:
|
54
|
+
name: ruby2-4_rails5-2
|
55
|
+
ruby_version: 2.4.6
|
56
|
+
rails_version: 5.2.3
|
57
|
+
- test:
|
58
|
+
name: ruby2-6_rails5-1
|
59
|
+
ruby_version: 2.6.3
|
60
|
+
rails_version: 5.1.7
|
61
|
+
- test:
|
62
|
+
name: ruby2-5_rails5-1
|
63
|
+
ruby_version: 2.5.5
|
64
|
+
rails_version: 5.1.7
|
65
|
+
- test:
|
66
|
+
name: ruby2-4_rails5-1
|
67
|
+
ruby_version: 2.4.6
|
68
|
+
rails_version: 5.1.7
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
inherit_gem:
|
2
|
+
bixby: bixby_default.yml
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
TargetRubyVersion: 2.4
|
6
|
+
|
7
|
+
Bundler/DuplicatedGem:
|
8
|
+
Exclude:
|
9
|
+
- 'Gemfile'
|
10
|
+
|
11
|
+
Metrics/BlockLength:
|
12
|
+
Exclude:
|
13
|
+
- 'spec/controllers/roles_controller_spec.rb'
|
14
|
+
- 'spec/controllers/user_roles_controller_spec.rb'
|
15
|
+
- 'spec/lib/user_roles_spec.rb'
|
16
|
+
- 'spec/models/role_spec.rb'
|
17
|
+
- 'spec/routing/role_management_routes_spec.rb'
|
18
|
+
|
19
|
+
Metrics/LineLength:
|
20
|
+
Exclude:
|
21
|
+
- ''
|
22
|
+
- 'lib/generators/roles/roles_generator.rb'
|
23
|
+
- 'spec/controllers/roles_controller_spec.rb'
|
24
|
+
- 'spec/controllers/user_roles_controller_spec.rb'
|
25
|
+
- 'spec/lib/user_roles_spec.rb'
|
26
|
+
- 'spec/routing/role_management_routes_spec.rb'
|
27
|
+
- 'spec/test_app_templates/config/initializers/hydra_config.rb'
|
28
|
+
|
29
|
+
Metrics/MethodLength:
|
30
|
+
Exclude:
|
31
|
+
- 'lib/generators/roles/roles_generator.rb'
|
32
|
+
|
33
|
+
Metrics/PerceivedComplexity:
|
34
|
+
Exclude:
|
35
|
+
- 'lib/generators/roles/roles_generator.rb'
|
36
|
+
|
37
|
+
Naming/FileName:
|
38
|
+
Exclude:
|
39
|
+
- 'Gemfile'
|
40
|
+
- 'hydra-role-management.gemspec'
|
41
|
+
- 'lib/hydra-role-management.rb'
|
42
|
+
|
43
|
+
Rails/HasAndBelongsToMany:
|
44
|
+
Exclude:
|
45
|
+
- 'app/models/concerns/hydra/role_management/user_roles.rb'
|
46
|
+
- 'app/models/role.rb'
|
47
|
+
|
48
|
+
RSpec/DescribeClass:
|
49
|
+
Exclude:
|
50
|
+
- 'spec/routing/role_management_routes_spec.rb'
|
data/CONTRIBUTING.md
CHANGED
@@ -1,21 +1,24 @@
|
|
1
1
|
# How to Contribute
|
2
2
|
|
3
|
-
We want your help to make
|
4
|
-
|
3
|
+
We want your help to make the Samvera community great. There are a few guidelines
|
4
|
+
that we need contributors to follow so that we can have a chance of
|
5
|
+
keeping on top of things.
|
5
6
|
|
6
7
|
## Code of Conduct
|
7
8
|
|
8
|
-
The
|
9
|
-
members, whether they are at a formal gathering, in
|
10
|
-
online.
|
11
|
-
for more information.
|
9
|
+
The Samvera Community is dedicated to providing a welcoming and positive
|
10
|
+
experience for all its members, whether they are at a formal gathering, in
|
11
|
+
a social setting, or taking part in activities online. Please see our
|
12
|
+
[Code of Conduct](CODE_OF_CONDUCT.md) for more information.
|
12
13
|
|
13
|
-
##
|
14
|
+
## Samvera Community Intellectual Property Licensing and Ownership
|
14
15
|
|
15
|
-
All code contributors must have an Individual Contributor License Agreement
|
16
|
-
|
16
|
+
All code contributors must have an Individual Contributor License Agreement
|
17
|
+
(iCLA) on file with the Samvera Steering Group. If the contributor works for
|
18
|
+
an institution, the institution must have a Corporate Contributor License
|
19
|
+
Agreement (cCLA) on file.
|
17
20
|
|
18
|
-
https://wiki.duraspace.org/display/
|
21
|
+
https://wiki.duraspace.org/display/samvera/Samvera+Community+Intellectual+Property+Licensing+and+Ownership
|
19
22
|
|
20
23
|
You should also add yourself to the `CONTRIBUTORS.md` file in the root of the project.
|
21
24
|
|
@@ -48,7 +51,7 @@ You should also add yourself to the `CONTRIBUTORS.md` file in the root of the pr
|
|
48
51
|
* Please avoid working directly on the `master` branch.
|
49
52
|
* You may find the [hub suite of commands](https://github.com/defunkt/hub) helpful
|
50
53
|
* Make sure you have added sufficient tests and documentation for your changes.
|
51
|
-
* Test functionality with RSpec;
|
54
|
+
* Test functionality with RSpec; Test features / UI with Capybara.
|
52
55
|
* Run _all_ the tests to assure nothing else was accidentally broken.
|
53
56
|
|
54
57
|
### Documenting Code
|
@@ -60,15 +63,11 @@ You should also add yourself to the `CONTRIBUTORS.md` file in the root of the pr
|
|
60
63
|
* If you don't know exactly what a bit of code does, it is extra likely that it needs to be documented. Take a stab at it and ask for feedback in your pull request. You can use the 'blame' button on GitHub to identify the original developer of the code and @mention them in your comment.
|
61
64
|
* This work greatly increases the usability of the code base and supports the on-ramping of new committers.
|
62
65
|
* We will all be understanding of one another's time constraints in this area.
|
63
|
-
* YARD examples:
|
64
|
-
* [Hydra::Works::RemoveGenericFile](https://github.com/projecthydra-labs/hydra-works/blob/master/lib/hydra/works/services/generic_work/remove_generic_file.rb)
|
65
|
-
* [ActiveTriples::LocalName::Minter](https://github.com/ActiveTriples/active_triples-local_name/blob/master/lib/active_triples/local_name/minter.rb)
|
66
66
|
* [Getting started with YARD](http://www.rubydoc.info/gems/yard/file/docs/GettingStarted.md)
|
67
67
|
|
68
68
|
### Committing changes
|
69
69
|
|
70
70
|
* Make commits of logical units.
|
71
|
-
* Your commit should include a high level description of your work in HISTORY.textile
|
72
71
|
* Check for unnecessary whitespace with `git diff --check` before committing.
|
73
72
|
* Make sure your commit messages are [well formed](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
|
74
73
|
* If you created an issue, you can close it by including "Closes #issue" in your commit message. See [Github's blog post for more details](https://github.com/blog/1386-closing-issues-via-commit-messages)
|
@@ -103,6 +102,10 @@ You should also add yourself to the `CONTRIBUTORS.md` file in the root of the pr
|
|
103
102
|
long to fit in 72 characters
|
104
103
|
```
|
105
104
|
|
105
|
+
* Make sure you have added the necessary tests for your changes.
|
106
|
+
* Run _all_ the tests to assure nothing else was accidentally broken.
|
107
|
+
* When you are ready to submit a pull request
|
108
|
+
|
106
109
|
### Submitting Changes
|
107
110
|
|
108
111
|
* Read the article ["Using Pull Requests"](https://help.github.com/articles/using-pull-requests) on GitHub.
|
@@ -125,9 +128,7 @@ We adopted [Github's Pull Request Review](https://help.github.com/articles/about
|
|
125
128
|
Common checks that may occur in our repositories:
|
126
129
|
|
127
130
|
1. Travis CI - where our automated tests are running
|
128
|
-
2.
|
129
|
-
3. Approval Required - Github enforces at least one person approve a pull request. Also, all reviewers that have chimed in must approve.
|
130
|
-
4. CodeClimate - is our code remaining healthy (at least according to static code analysis)
|
131
|
+
2. Approval Required - Github enforces at least one person approve a pull request. Also, all reviewers that have chimed in must approve.
|
131
132
|
|
132
133
|
If one or more of the required checks failed (or are incomplete), the code should not be merged (and the UI will not allow it). If all of the checks have passed, then anyone on the project (including the pull request submitter) may merge the code.
|
133
134
|
|
@@ -144,16 +145,17 @@ First, the person contributing the code is putting themselves out there. Be mind
|
|
144
145
|
This is your chance for a mentoring moment of another developer. Take time to give an honest and thorough review of what has changed. Things to consider:
|
145
146
|
|
146
147
|
* Does the commit message explain what is going on?
|
147
|
-
* Does the code changes have tests? _Not all changes need new tests, some changes are
|
148
|
+
* Does the code changes have tests? _Not all changes need new tests, some changes are refactorings_
|
148
149
|
* Do new or changed methods, modules, and classes have documentation?
|
149
150
|
* Does the commit contain more than it should? Are two separate concerns being addressed in one commit?
|
150
151
|
* Does the description of the new/changed specs match your understanding of what the spec is doing?
|
152
|
+
* Did the Travis tests complete successfully?
|
151
153
|
|
152
154
|
If you are uncertain, bring other contributors into the conversation by assigning them as a reviewer.
|
153
155
|
|
154
156
|
# Additional Resources
|
155
157
|
|
156
158
|
* [General GitHub documentation](http://help.github.com/)
|
157
|
-
* [GitHub pull request documentation](
|
159
|
+
* [GitHub pull request documentation](https://help.github.com/articles/about-pull-requests/)
|
158
160
|
* [Pro Git](http://git-scm.com/book) is both a free and excellent book about Git.
|
159
161
|
* [A Git Config for Contributing](http://ndlib.github.io/practices/my-typical-per-project-git-config/)
|
data/Gemfile
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
source "https://rubygems.org"
|
2
3
|
|
3
4
|
gem 'coveralls', require: false
|
@@ -8,8 +9,7 @@ gemspec
|
|
8
9
|
# engine_cart: 1.1.0
|
9
10
|
# engine_cart stanza: 0.10.0
|
10
11
|
# the below comes from engine_cart, a gem used to test this Rails engine gem in the context of a Rails app.
|
11
|
-
file = File.expand_path('Gemfile', ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || File.expand_path('.internal_test_app', File.dirname(__FILE__
|
12
|
-
)))
|
12
|
+
file = File.expand_path('Gemfile', ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || File.expand_path('.internal_test_app', File.dirname(__FILE__)))
|
13
13
|
if File.exist?(file)
|
14
14
|
begin
|
15
15
|
eval_gemfile file
|
@@ -31,9 +31,9 @@ else
|
|
31
31
|
|
32
32
|
case ENV['RAILS_VERSION']
|
33
33
|
when /^4.2/
|
34
|
+
gem 'coffee-rails', '~> 4.1.0'
|
34
35
|
gem 'responders', '~> 2.0'
|
35
36
|
gem 'sass-rails', '>= 5.0'
|
36
|
-
gem 'coffee-rails', '~> 4.1.0'
|
37
37
|
when /^4.[01]/
|
38
38
|
gem 'sass-rails', '< 5.0'
|
39
39
|
end
|
data/README.md
CHANGED
@@ -1,12 +1,37 @@
|
|
1
1
|
# hydra-role-management
|
2
2
|
|
3
|
-
|
3
|
+
Code:
|
4
|
+
[![CircleCI](https://circleci.com/gh/samvera/hydra-role-management.svg?style=svg)](https://circleci.com/gh/samvera/hydra-role-management)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/hydra-role-management.svg)](https://badge.fury.io/rb/hydra-role-management)
|
6
|
+
[![Coverage Status](https://coveralls.io/repos/github/samvera/hydra-role-management/badge.svg?branch=master)](https://coveralls.io/github/samvera/hydra-role-management?branch=master)
|
4
7
|
|
8
|
+
Docs:
|
9
|
+
[![Contribution Guidelines](http://img.shields.io/badge/CONTRIBUTING-Guidelines-blue.svg)](./CONTRIBUTING.md)
|
10
|
+
[![Apache 2.0 License](http://img.shields.io/badge/APACHE2-license-blue.svg)](./LICENSE.md)
|
11
|
+
|
12
|
+
Jump In:
|
13
|
+
[![Slack Status](http://slack.samvera.org/badge.svg)](http://slack.samvera.org/)
|
14
|
+
|
15
|
+
# What is hydra-role-management?
|
5
16
|
|
6
17
|
An engine gem to provide a RDBMS backed list of roles and their associated user. This replaces the hydra default role mapper.
|
7
18
|
|
8
19
|
As of version 1.0, this gem only supports Rails 5.
|
9
20
|
|
21
|
+
## Product Owner & Maintenance
|
22
|
+
|
23
|
+
**hydra-role-management** is a Core Component of the Samvera community. The documentation for
|
24
|
+
what this means can be found
|
25
|
+
[here](http://samvera.github.io/core_components.html#requirements-for-a-core-component).
|
26
|
+
|
27
|
+
### Product Owner
|
28
|
+
|
29
|
+
[jrgriffiniii](https://github.com/jrgriffiniii)
|
30
|
+
|
31
|
+
# Help
|
32
|
+
|
33
|
+
The Samvera community is here to help. Please see our [support guide](./SUPPORT.md).
|
34
|
+
|
10
35
|
## Installing:
|
11
36
|
|
12
37
|
* Add: ```gem 'hydra-role-management'``` to your Gemfile and then ```bundle install```
|
@@ -30,3 +55,10 @@ As of version 1.0, this gem only supports Rails 5.
|
|
30
55
|
* Ensure that the correct version of Rails is installed: ```bundle update```
|
31
56
|
* Build test app: ```bundle exec rake engine_cart:generate```
|
32
57
|
* And run tests: ```bundle exec rake spec```
|
58
|
+
|
59
|
+
# Acknowledgments
|
60
|
+
|
61
|
+
This software has been developed by and is brought to you by the Samvera community. Learn more at the
|
62
|
+
[Samvera website](http://samvera.org/).
|
63
|
+
|
64
|
+
![Samvera Logo](https://wiki.duraspace.org/download/thumbnails/87459292/samvera-fall-font2-200w.png?version=1&modificationDate=1498550535816&api=v2)
|
data/Rakefile
CHANGED
@@ -1,23 +1,20 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
+
# frozen_string_literal: true
|
2
3
|
require 'bundler/setup'
|
3
|
-
require
|
4
|
-
|
5
|
-
require 'rspec/core/rake_task'
|
4
|
+
require 'bundler/gem_tasks'
|
6
5
|
require 'engine_cart/rake_task'
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
require 'rubocop/rake_task'
|
7
8
|
|
9
|
+
desc 'Run style checker'
|
10
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
11
|
+
task.fail_on_error = true
|
12
|
+
end
|
8
13
|
|
9
|
-
desc '
|
10
|
-
task :
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
task :ci => [:clean, :generate, :spec]
|
15
|
-
|
16
|
-
desc "Run the tests"
|
17
|
-
RSpec::Core::RakeTask.new(:spec)
|
18
|
-
|
19
|
-
desc "Create the test rails app"
|
20
|
-
task :generate => 'engine_cart:generate'
|
14
|
+
desc 'Run the tests'
|
15
|
+
task ci: [:rubocop, 'engine_cart:generate'] do
|
16
|
+
RSpec::Core::RakeTask.new(:spec)
|
17
|
+
Rake::Task['spec'].invoke
|
18
|
+
end
|
21
19
|
|
22
|
-
|
23
|
-
task :clean => 'engine_cart:clean'
|
20
|
+
task default: :ci
|
data/SUPPORT.md
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
If you would like to report an issue, first search [the list of issues](https://github.com/samvera/hydra-role-management/issues/) to see if someone else has already reported it, and then feel free to [create a new issue](https://github.com/samvera/hydra-role-management/issues/new).
|
2
|
+
|
3
|
+
If you have questions or need help, please email [the Samvera community tech list](https://groups.google.com/forum/#!forum/samvera-tech) or stop by the #dev channel in [the Samvera community Slack team](https://wiki.duraspace.org/pages/viewpage.action?pageId=87460391#Getintouch!-Slack).
|
4
|
+
|
5
|
+
You can learn more about the various Samvera communication channels on the [Get in touch!](https://wiki.duraspace.org/pages/viewpage.action?pageId=87460391) wiki page.
|
6
|
+
|
@@ -1,31 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Hydra
|
2
3
|
module RoleManagement
|
4
|
+
# Module defining Controller actions for creating and managing Roles
|
3
5
|
module RolesBehavior
|
4
6
|
extend ActiveSupport::Concern
|
5
7
|
|
6
8
|
included do
|
7
|
-
load_and_authorize_resource
|
9
|
+
load_and_authorize_resource
|
8
10
|
end
|
9
11
|
|
10
|
-
def index
|
11
|
-
end
|
12
|
+
def index; end
|
12
13
|
|
13
14
|
def show
|
14
15
|
redirect_to role_management.edit_role_path(@role) if can? :edit, @role
|
15
16
|
end
|
16
17
|
|
17
|
-
def new
|
18
|
-
end
|
18
|
+
def new; end
|
19
19
|
|
20
|
-
def edit
|
21
|
-
end
|
20
|
+
def edit; end
|
22
21
|
|
23
22
|
def create
|
24
23
|
@role = Role.new(role_params)
|
25
24
|
if @role.save
|
26
25
|
redirect_to role_management.edit_role_path(@role), notice: 'Role was successfully created.'
|
27
26
|
else
|
28
|
-
render action:
|
27
|
+
render action: 'new'
|
29
28
|
end
|
30
29
|
end
|
31
30
|
|
@@ -34,12 +33,12 @@ module Hydra
|
|
34
33
|
if @role.update_attributes(role_params)
|
35
34
|
redirect_to role_management.edit_role_path(@role), notice: 'Role was successfully updated.'
|
36
35
|
else
|
37
|
-
render action:
|
36
|
+
render action: 'edit'
|
38
37
|
end
|
39
38
|
end
|
40
39
|
|
41
40
|
def destroy
|
42
|
-
if
|
41
|
+
if @role.destroy
|
43
42
|
redirect_to role_management.roles_path, notice: 'Role was successfully deleted.'
|
44
43
|
else
|
45
44
|
redirect_to role_management.roles_path
|
@@ -48,13 +47,13 @@ module Hydra
|
|
48
47
|
|
49
48
|
private
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
50
|
+
def role_params
|
51
|
+
if !ActionController.const_defined? :StrongParameters
|
52
|
+
params[:role]
|
53
|
+
else
|
54
|
+
params.require(:role).permit(:name)
|
55
|
+
end
|
56
56
|
end
|
57
|
-
end
|
58
57
|
end
|
59
58
|
end
|
60
59
|
end
|
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Hydra
|
2
3
|
module RoleManagement
|
4
|
+
# Module defining Controller actions for adding and managing Roles for Users
|
3
5
|
module UserRolesBehavior
|
4
6
|
extend ActiveSupport::Concern
|
5
7
|
|
@@ -15,7 +17,7 @@ module Hydra
|
|
15
17
|
u.save!
|
16
18
|
redirect_to role_management.role_path(@role)
|
17
19
|
else
|
18
|
-
redirect_to role_management.role_path(@role), :
|
20
|
+
redirect_to role_management.role_path(@role), flash: { error: "Unable to find the user #{params[:user_key]}" }
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
@@ -27,14 +29,13 @@ module Hydra
|
|
27
29
|
|
28
30
|
protected
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
def find_user
|
33
|
+
::User.send("find_by_#{find_column}".to_sym, params[:user_key])
|
34
|
+
end
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
|
36
|
+
def find_column
|
37
|
+
Devise.authentication_keys.first
|
38
|
+
end
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
40
|
-
|