hydra-role-management 0.2.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rspec +2 -0
- data/.travis.yml +7 -14
- data/CONTRIBUTING.md +66 -20
- data/Gemfile +34 -8
- data/README.md +11 -7
- data/app/views/roles/edit.html.erb +10 -10
- data/app/views/roles/index.html.erb +2 -2
- data/app/views/roles/new.html.erb +3 -3
- data/app/views/roles/show.html.erb +7 -7
- data/config/locales/role-management.en.yml +28 -0
- data/config/locales/role-management.es.yml +28 -0
- data/hydra-role-management.gemspec +3 -2
- data/lib/generators/roles/templates/migrations/user_roles.rb +1 -1
- data/lib/hydra/role_management/version.rb +1 -1
- data/spec/controllers/roles_controller_spec.rb +15 -18
- data/spec/controllers/user_roles_controller_spec.rb +6 -9
- data/spec/lib/user_roles_spec.rb +0 -2
- data/spec/models/role_spec.rb +0 -2
- data/spec/routing/role_management_routes_spec.rb +12 -14
- data/spec/spec_helper.rb +11 -5
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +6 -11
- metadata +24 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29cc644bd9c4ab4e8b33f15ac0391b512cbd0ed2
|
4
|
+
data.tar.gz: fae1f29f174e38105242a148bd04cde1d50cca15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05c99ba950eba5d946efdfd33518e23de53c689c39c0e7b1e243b478da5daed56ce2ade1782c4b7a5aa44a261b4177e745163b3fe99ccc532bee54bac22d1053
|
7
|
+
data.tar.gz: 864ddfbd1372fda98f0bc004709f13a805ea45e498587c08745fd16bcb5229f0761fe4966965f6cfb94257bec2f44e18b22f557a0678bc09cb4a62468add1a75
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.travis.yml
CHANGED
@@ -1,18 +1,11 @@
|
|
1
1
|
language: ruby
|
2
|
+
sudo: false
|
3
|
+
cache:
|
4
|
+
bundler: true
|
2
5
|
rvm:
|
3
|
-
- 2.
|
4
|
-
- 2.1
|
6
|
+
- 2.4.2
|
5
7
|
env:
|
6
8
|
global:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
recipients:
|
11
|
-
- "justin@curationexperts.com"
|
12
|
-
on_success: "change"
|
13
|
-
on_failure: "always"
|
14
|
-
irc:
|
15
|
-
channels:
|
16
|
-
- "irc.freenode.org#projecthydra"
|
17
|
-
template:
|
18
|
-
- "%{repository}//%{branch}@%{commit} by %{author}: %{message} - %{build_url}"
|
9
|
+
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
10
|
+
matrix:
|
11
|
+
- RAILS_VERSION=5.1.4
|
data/CONTRIBUTING.md
CHANGED
@@ -3,6 +3,13 @@
|
|
3
3
|
We want your help to make Project Hydra great.
|
4
4
|
There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
|
5
5
|
|
6
|
+
## Code of Conduct
|
7
|
+
|
8
|
+
The Hydra community is dedicated to providing a welcoming and positive experience for all its
|
9
|
+
members, whether they are at a formal gathering, in a social setting, or taking part in activities
|
10
|
+
online. Please see our [Code of Conduct](https://wiki.duraspace.org/display/hydra/Code+of+Conduct)
|
11
|
+
for more information.
|
12
|
+
|
6
13
|
## Hydra Project Intellectual Property Licensing and Ownership
|
7
14
|
|
8
15
|
All code contributors must have an Individual Contributor License Agreement (iCLA) on file with the Hydra Project Steering Group.
|
@@ -16,8 +23,10 @@ You should also add yourself to the `CONTRIBUTORS.md` file in the root of the pr
|
|
16
23
|
|
17
24
|
* Reporting Issues
|
18
25
|
* Making Changes
|
26
|
+
* Documenting Code
|
27
|
+
* Committing Changes
|
19
28
|
* Submitting Changes
|
20
|
-
* Merging Changes
|
29
|
+
* Reviewing and Merging Changes
|
21
30
|
|
22
31
|
### Reporting Issues
|
23
32
|
|
@@ -38,8 +47,28 @@ You should also add yourself to the `CONTRIBUTORS.md` file in the root of the pr
|
|
38
47
|
* Then checkout the new branch with `git checkout fix/master/my_contribution`.
|
39
48
|
* Please avoid working directly on the `master` branch.
|
40
49
|
* You may find the [hub suite of commands](https://github.com/defunkt/hub) helpful
|
50
|
+
* Make sure you have added sufficient tests and documentation for your changes.
|
51
|
+
* Test functionality with RSpec; est features / UI with Capybara.
|
52
|
+
* Run _all_ the tests to assure nothing else was accidentally broken.
|
53
|
+
|
54
|
+
### Documenting Code
|
55
|
+
|
56
|
+
* All new public methods, modules, and classes should include inline documentation in [YARD](http://yardoc.org/).
|
57
|
+
* Documentation should seek to answer the question "why does this code exist?"
|
58
|
+
* Document private / protected methods as desired.
|
59
|
+
* If you are working in a file with no prior documentation, do try to document as you gain understanding of the code.
|
60
|
+
* 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
|
+
* This work greatly increases the usability of the code base and supports the on-ramping of new committers.
|
62
|
+
* 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
|
+
* [Getting started with YARD](http://www.rubydoc.info/gems/yard/file/docs/GettingStarted.md)
|
67
|
+
|
68
|
+
### Committing changes
|
69
|
+
|
41
70
|
* Make commits of logical units.
|
42
|
-
* Your commit should include a high level description of your work in HISTORY.textile
|
71
|
+
* Your commit should include a high level description of your work in HISTORY.textile
|
43
72
|
* Check for unnecessary whitespace with `git diff --check` before committing.
|
44
73
|
* Make sure your commit messages are [well formed](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
|
45
74
|
* 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)
|
@@ -60,7 +89,9 @@ You should also add yourself to the `CONTRIBUTORS.md` file in the root of the pr
|
|
60
89
|
|
61
90
|
class PostsController
|
62
91
|
def index
|
63
|
-
|
92
|
+
respond_to do |wants|
|
93
|
+
wants.html { render 'index' }
|
94
|
+
end
|
64
95
|
end
|
65
96
|
end
|
66
97
|
|
@@ -72,38 +103,53 @@ You should also add yourself to the `CONTRIBUTORS.md` file in the root of the pr
|
|
72
103
|
long to fit in 72 characters
|
73
104
|
```
|
74
105
|
|
75
|
-
* Make sure you have added the necessary tests for your changes.
|
76
|
-
* Run _all_ the tests to assure nothing else was accidentally broken.
|
77
|
-
* When you are ready to submit a pull request
|
78
|
-
|
79
106
|
### Submitting Changes
|
80
107
|
|
81
|
-
[Detailed Walkthrough of One Pull Request per Commit](http://ndlib.github.io/practices/one-commit-per-pull-request/)
|
82
|
-
|
83
108
|
* Read the article ["Using Pull Requests"](https://help.github.com/articles/using-pull-requests) on GitHub.
|
84
109
|
* Make sure your branch is up to date with its parent branch (i.e. master)
|
85
110
|
* `git checkout master`
|
86
111
|
* `git pull --rebase`
|
87
112
|
* `git checkout <your-branch>`
|
88
113
|
* `git rebase master`
|
89
|
-
* It is
|
90
|
-
*
|
91
|
-
*
|
92
|
-
*
|
114
|
+
* It is a good idea to run your tests again.
|
115
|
+
* If you've made more than one commit take a moment to consider whether squashing commits together would help improve their logical grouping.
|
116
|
+
* [Detailed Walkthrough of One Pull Request per Commit](http://ndlib.github.io/practices/one-commit-per-pull-request/)
|
117
|
+
* `git rebase --interactive master` ([See Github help](https://help.github.com/articles/interactive-rebase))
|
93
118
|
* Squashing your branch's changes into one commit is "good form" and helps the person merging your request to see everything that is going on.
|
94
119
|
* Push your changes to a topic branch in your fork of the repository.
|
95
120
|
* Submit a pull request from your fork to the project.
|
96
121
|
|
97
|
-
### Merging Changes
|
122
|
+
### Reviewing and Merging Changes
|
123
|
+
|
124
|
+
We adopted [Github's Pull Request Review](https://help.github.com/articles/about-pull-request-reviews/) for our repositories.
|
125
|
+
Common checks that may occur in our repositories:
|
126
|
+
|
127
|
+
1. Travis CI - where our automated tests are running
|
128
|
+
2. Hound CI - where we check for style violations
|
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
|
+
|
132
|
+
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
|
+
*Example: Carolyn submits a pull request, Justin reviews the pull request and approves. However, Justin is still waiting on other checks (Travis CI is usually the culprit), so he does not merge the pull request. Eventually, all of the checks pass. At this point, Carolyn or anyone else may merge the pull request.*
|
135
|
+
|
136
|
+
#### Things to Consider When Reviewing
|
137
|
+
|
138
|
+
First, the person contributing the code is putting themselves out there. Be mindful of what you say in a review.
|
139
|
+
|
140
|
+
* Ask clarifying questions
|
141
|
+
* State your understanding and expectations
|
142
|
+
* Provide example code or alternate solutions, and explain why
|
143
|
+
|
144
|
+
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:
|
98
145
|
|
99
|
-
* It is considered "poor from" to merge your own request.
|
100
|
-
* Please take the time to review the changes and get a sense of what is being changed. Things to consider:
|
101
146
|
* Does the commit message explain what is going on?
|
102
|
-
* Does the code changes have tests? _Not all changes need new tests, some changes are
|
147
|
+
* Does the code changes have tests? _Not all changes need new tests, some changes are refactors_
|
148
|
+
* Do new or changed methods, modules, and classes have documentation?
|
103
149
|
* Does the commit contain more than it should? Are two separate concerns being addressed in one commit?
|
104
|
-
*
|
105
|
-
|
106
|
-
|
150
|
+
* Does the description of the new/changed specs match your understanding of what the spec is doing?
|
151
|
+
|
152
|
+
If you are uncertain, bring other contributors into the conversation by assigning them as a reviewer.
|
107
153
|
|
108
154
|
# Additional Resources
|
109
155
|
|
data/Gemfile
CHANGED
@@ -1,15 +1,41 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
|
3
|
+
gem 'coveralls', require: false
|
4
|
+
|
3
5
|
gemspec
|
4
6
|
|
5
|
-
|
7
|
+
# BEGIN ENGINE_CART BLOCK
|
8
|
+
# engine_cart: 1.1.0
|
9
|
+
# engine_cart stanza: 0.10.0
|
10
|
+
# 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
|
+
)))
|
13
|
+
if File.exist?(file)
|
14
|
+
begin
|
15
|
+
eval_gemfile file
|
16
|
+
rescue Bundler::GemfileError => e
|
17
|
+
Bundler.ui.warn '[EngineCart] Skipping Rails application dependencies:'
|
18
|
+
Bundler.ui.warn e.message
|
19
|
+
end
|
20
|
+
else
|
21
|
+
Bundler.ui.warn "[EngineCart] Unable to find test application dependencies in #{file}, using placeholder dependencies"
|
6
22
|
|
7
|
-
|
8
|
-
|
9
|
-
gem '
|
23
|
+
if ENV['RAILS_VERSION']
|
24
|
+
if ENV['RAILS_VERSION'] == 'edge'
|
25
|
+
gem 'rails', github: 'rails/rails'
|
26
|
+
ENV['ENGINE_CART_RAILS_OPTIONS'] = '--edge --skip-turbolinks'
|
27
|
+
else
|
28
|
+
gem 'rails', ENV['RAILS_VERSION']
|
29
|
+
end
|
30
|
+
end
|
10
31
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
32
|
+
case ENV['RAILS_VERSION']
|
33
|
+
when /^4.2/
|
34
|
+
gem 'responders', '~> 2.0'
|
35
|
+
gem 'sass-rails', '>= 5.0'
|
36
|
+
gem 'coffee-rails', '~> 4.1.0'
|
37
|
+
when /^4.[01]/
|
38
|
+
gem 'sass-rails', '< 5.0'
|
39
|
+
end
|
15
40
|
end
|
41
|
+
# END ENGINE_CART BLOCK
|
data/README.md
CHANGED
@@ -1,8 +1,13 @@
|
|
1
|
+
# hydra-role-management
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/samvera/hydra-role-management.svg?branch=master)](https://travis-ci.org/samvera/hydra-role-management) [![Gem Version](https://badge.fury.io/rb/hydra-role-management.svg)](https://badge.fury.io/rb/hydra-role-management) [![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
|
+
|
5
|
+
|
1
6
|
An engine gem to provide a RDBMS backed list of roles and their associated user. This replaces the hydra default role mapper.
|
2
7
|
|
3
|
-
|
8
|
+
As of version 1.0, this gem only supports Rails 5.
|
4
9
|
|
5
|
-
##Installing:
|
10
|
+
## Installing:
|
6
11
|
|
7
12
|
* Add: ```gem 'hydra-role-management'``` to your Gemfile and then ```bundle install```
|
8
13
|
* ```rails generate roles```
|
@@ -12,17 +17,16 @@ This gem supports both Rails 3 and 4.
|
|
12
17
|
```
|
13
18
|
# app/models/ability.rb
|
14
19
|
if current_user.admin?
|
15
|
-
can [:create, :show, :add_user, :remove_user, :index], Role
|
20
|
+
can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role
|
16
21
|
end
|
17
22
|
```
|
18
23
|
|
19
|
-
##Testing:
|
20
|
-
Given the need to support both Rails 3 and 4, the test suite has been parameterized to test against any version of Rails.
|
24
|
+
## Testing:
|
21
25
|
|
22
26
|
* Install a system javascript runtime or uncomment therubyracer in spec/support/Gemfile
|
23
27
|
* Ensure that the testing app does not exist: ```bundle exec rake clean```
|
24
28
|
* Set Rails version you want to test against. For example:
|
25
|
-
* ```RAILS_VERSION=
|
29
|
+
* ```export RAILS_VERSION=5.1.4```
|
26
30
|
* Ensure that the correct version of Rails is installed: ```bundle update```
|
27
|
-
* Build test app: ```bundle exec engine_cart:generate```
|
31
|
+
* Build test app: ```bundle exec rake engine_cart:generate```
|
28
32
|
* And run tests: ```bundle exec rake spec```
|
@@ -1,26 +1,26 @@
|
|
1
|
-
<h2
|
1
|
+
<h2><%= t('role-management.edit.title') %></h2>
|
2
2
|
<%= bootstrap_form_for @role, :url=>role_management.role_path(@role) do |f| %>
|
3
|
-
<%= f.text_field :name, :label=> '
|
3
|
+
<%= f.text_field :name, :label=> t('role-management.edit.field_name') %>
|
4
4
|
|
5
|
-
<%= f.submit
|
5
|
+
<%= f.submit t('role-management.edit.update') %>
|
6
6
|
|
7
7
|
<% end %>
|
8
8
|
<% if can? :destroy, Role %>
|
9
|
-
<%= button_to
|
9
|
+
<%= button_to t('role-management.edit.delete'), role_management.role_path(@role), :method=>:delete, :class=>'btn btn-danger' %>
|
10
10
|
<% end %>
|
11
|
-
<h3
|
11
|
+
<h3><%= t('role-management.edit.accounts') %></h3>
|
12
12
|
<ul>
|
13
13
|
<% @role.users.each do |user| %>
|
14
14
|
<li><%= user.user_key %>
|
15
15
|
<% if can? :remove_user, Role %>
|
16
|
-
<%= button_to
|
16
|
+
<%= button_to t('role-management.edit.remove'), role_management.role_user_path(@role, user), :method=>:delete, :class=>'btn btn-danger' %>
|
17
17
|
<% end %>
|
18
18
|
</li>
|
19
19
|
<% end %>
|
20
20
|
</ul>
|
21
|
-
<h3
|
21
|
+
<h3><%= t('role-management.edit.add_new_account') %></h3>
|
22
22
|
<%= bootstrap_form_tag :url=> role_management.role_users_path(@role) do |f| %>
|
23
|
-
<%= f.text_field 'user_key', :label=>'
|
24
|
-
<%= f.submit
|
25
|
-
<%= link_to
|
23
|
+
<%= f.text_field 'user_key', :label=>t('role-management.edit.user') %>
|
24
|
+
<%= f.submit t('role-management.edit.add') %>
|
25
|
+
<%= link_to t('role-management.edit.cancel'), role_management.roles_path, :class => 'btn btn-default' %>
|
26
26
|
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<h2
|
1
|
+
<h2><%= t('role-management.index.title') %></h2>
|
2
2
|
<ul>
|
3
3
|
<% @roles.each do |role| %>
|
4
4
|
<li><%=link_to role.name, role_management.role_path(role) %></li>
|
@@ -6,6 +6,6 @@
|
|
6
6
|
</ul>
|
7
7
|
|
8
8
|
<% if can? :create, Role %>
|
9
|
-
<%= button_to
|
9
|
+
<%= button_to t('role-management.index.create'), role_management.new_role_path, method: :get, class: 'btn btn-primary' %>
|
10
10
|
<% end %>
|
11
11
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%= bootstrap_form_for @role, :url=>role_management.roles_path do |f| %>
|
2
|
-
<%= f.text_field :name, :label=> '
|
3
|
-
<%= f.submit
|
4
|
-
<%= link_to
|
2
|
+
<%= f.text_field :name, :label=> t('role-management.new.field_name') %>
|
3
|
+
<%= f.submit t('role-management.new.add') %>
|
4
|
+
<%= link_to t('role-management.new.cancel'), role_management.roles_path, :class => 'btn btn-default' %>
|
5
5
|
<% end %>
|
6
6
|
|
@@ -1,17 +1,17 @@
|
|
1
|
-
<h2
|
2
|
-
<h3
|
1
|
+
<h2><%= t('role-management.show.title') %> <%= @role.name %></h2>
|
2
|
+
<h3><% t('role-management.show.accounts') %></h3>
|
3
3
|
<ul>
|
4
4
|
<% @role.users.each do |user| %>
|
5
5
|
<li><%= user.user_key %>
|
6
6
|
<% if can? :remove_user, Role %>
|
7
|
-
<%= button_to
|
7
|
+
<%= button_to t('role-management.show.remove'), role_management.role_user_path(@role, user), :method=>:delete, :class=>'btn btn-danger' %>
|
8
8
|
<% end %>
|
9
9
|
</li>
|
10
10
|
<% end %>
|
11
11
|
</ul>
|
12
|
-
<h3
|
12
|
+
<h3><%= t('role-management.show.add_new_account') %></h3>
|
13
13
|
<%= bootstrap_form_tag url: role_management.role_users_path(@role) do |f| %>
|
14
|
-
<%= f.text_field 'user_key', :label=>'
|
15
|
-
<%= f.submit
|
16
|
-
<%= link_to
|
14
|
+
<%= f.text_field 'user_key', :label=>t('role-management.show.user') %>
|
15
|
+
<%= f.submit t('role-management.show.add') %>
|
16
|
+
<%= link_to t('role-management.show.cancel'), role_management.roles_path, :class => 'btn btn-default' %>
|
17
17
|
<% end %>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
en:
|
2
|
+
role-management:
|
3
|
+
index:
|
4
|
+
title: 'Roles'
|
5
|
+
create: 'Create a new role'
|
6
|
+
new:
|
7
|
+
field_name: 'Role name'
|
8
|
+
add: 'Add'
|
9
|
+
cancel: 'Cancel'
|
10
|
+
show:
|
11
|
+
title: 'Role:'
|
12
|
+
accounts: 'Accounts:'
|
13
|
+
remove: 'Remove User'
|
14
|
+
add_new_account: 'Add a new account:'
|
15
|
+
user: 'User'
|
16
|
+
add: 'Add'
|
17
|
+
cancel: 'Cancel'
|
18
|
+
edit:
|
19
|
+
title: 'Role:'
|
20
|
+
field_name: 'Role name'
|
21
|
+
update: 'Update'
|
22
|
+
accounts: 'Accounts:'
|
23
|
+
delete: 'Delete'
|
24
|
+
remove: 'Remove User'
|
25
|
+
add_new_account: 'Add a new account:'
|
26
|
+
user: 'User'
|
27
|
+
add: 'Add'
|
28
|
+
cancel: 'Cancel'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
es:
|
2
|
+
role-management:
|
3
|
+
index:
|
4
|
+
title: 'Rols'
|
5
|
+
create: 'Crear un nuevo rol'
|
6
|
+
new:
|
7
|
+
field_name: 'Nombre de rol'
|
8
|
+
add: 'Añadir'
|
9
|
+
cancel: 'Cancelar'
|
10
|
+
show:
|
11
|
+
title: 'Rol:'
|
12
|
+
accounts: 'Cuentas:'
|
13
|
+
remove: 'Eliminar Usuario'
|
14
|
+
add_new_account: 'Añadir una cuenta nueva:'
|
15
|
+
user: 'Usuario'
|
16
|
+
add: 'Añadir'
|
17
|
+
cancel: 'Cancelar'
|
18
|
+
edit:
|
19
|
+
title: 'Rol:'
|
20
|
+
field_name: 'Nombre de rol'
|
21
|
+
update: 'Actualizar'
|
22
|
+
accounts: 'Cuentas:'
|
23
|
+
delete: 'Borrar'
|
24
|
+
remove: 'Eliminar Usuario'
|
25
|
+
add_new_account: 'Añadir una cuenta nueva:'
|
26
|
+
user: 'Usuario'
|
27
|
+
add: 'Añadir'
|
28
|
+
cancel: 'Cancelar'
|
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.email = ["justin@curationexperts.com"]
|
7
7
|
gem.description = %q{Rails engine to do user roles in an RDBMS for hydra-head}
|
8
8
|
gem.summary = %q{Rails engine to do user roles in an RDBMS for hydra-head}
|
9
|
-
gem.homepage = "https://github.com/
|
9
|
+
gem.homepage = "https://github.com/samvera/hydra-role-management"
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
12
12
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -22,5 +22,6 @@ Gem::Specification.new do |gem|
|
|
22
22
|
gem.add_development_dependency 'rake'
|
23
23
|
gem.add_development_dependency 'rspec-rails'
|
24
24
|
gem.add_development_dependency 'rspec-its'
|
25
|
-
gem.add_development_dependency '
|
25
|
+
gem.add_development_dependency 'rails-controller-testing', '~> 0'
|
26
|
+
gem.add_development_dependency 'engine_cart', '~> 1.0'
|
26
27
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe RolesController do
|
4
2
|
let(:ability) do
|
5
3
|
ability = Object.new
|
@@ -12,28 +10,28 @@ describe RolesController do
|
|
12
10
|
Role.create(name: 'foo')
|
13
11
|
end
|
14
12
|
|
15
|
-
before(:each) do
|
13
|
+
before(:each) do
|
16
14
|
@routes = Hydra::RoleManagement::Engine.routes
|
17
15
|
end
|
18
|
-
|
16
|
+
|
19
17
|
describe "with a user who cannot edit roles" do
|
20
18
|
it "should not be able to view role index" do
|
21
|
-
expect {get :index}.to raise_error CanCan::AccessDenied
|
19
|
+
expect { get :index, params: {} }.to raise_error CanCan::AccessDenied
|
22
20
|
end
|
23
21
|
it "should not be able to view role" do
|
24
|
-
expect {get :show, id: role}.to raise_error CanCan::AccessDenied
|
22
|
+
expect { get :show, params: { id: role } }.to raise_error CanCan::AccessDenied
|
25
23
|
end
|
26
24
|
it "should not be able to view new role form" do
|
27
25
|
expect { get :new }.to raise_error CanCan::AccessDenied
|
28
26
|
end
|
29
27
|
it "should not be able to create a role" do
|
30
|
-
expect { post :create, :role
|
28
|
+
expect { post :create, params: { role: { name: 'my_role' } } }.to raise_error CanCan::AccessDenied
|
31
29
|
end
|
32
30
|
it "should not be able to update a role" do
|
33
|
-
expect { put :update, id: role}.to raise_error CanCan::AccessDenied
|
31
|
+
expect { put :update, params: { id: role } }.to raise_error CanCan::AccessDenied
|
34
32
|
end
|
35
33
|
it "should not be able to remove a role" do
|
36
|
-
expect { delete :destroy, id: role}.to raise_error CanCan::AccessDenied
|
34
|
+
expect { delete :destroy, params: { id: role } }.to raise_error CanCan::AccessDenied
|
37
35
|
end
|
38
36
|
end
|
39
37
|
|
@@ -48,7 +46,7 @@ describe RolesController do
|
|
48
46
|
end
|
49
47
|
|
50
48
|
it "should be able to see a single role" do
|
51
|
-
get :show, id: role
|
49
|
+
get :show, params: { id: role }
|
52
50
|
expect(response).to be_successful
|
53
51
|
expect(assigns[:role]).to eq role
|
54
52
|
end
|
@@ -58,11 +56,11 @@ describe RolesController do
|
|
58
56
|
it "should be redirected to edit" do
|
59
57
|
ability.can :read, Role
|
60
58
|
ability.can :update, Role, id: role.id
|
61
|
-
get :show, id: role
|
59
|
+
get :show, params: { id: role }
|
62
60
|
expect(response).to redirect_to @routes.url_helpers.edit_role_path(assigns[:role])
|
63
61
|
end
|
64
62
|
end
|
65
|
-
|
63
|
+
|
66
64
|
describe "with a user who can create roles" do
|
67
65
|
before do
|
68
66
|
ability.can :create, Role
|
@@ -74,13 +72,13 @@ describe RolesController do
|
|
74
72
|
end
|
75
73
|
|
76
74
|
it "should be able to create a new role" do
|
77
|
-
post :create, :role
|
75
|
+
post :create, params: { role: { name: 'my_role' } }
|
78
76
|
expect(response).to redirect_to @routes.url_helpers.edit_role_path(assigns[:role])
|
79
77
|
expect(assigns[:role]).not_to be_new_record
|
80
78
|
expect(assigns[:role].name).to eq 'my_role'
|
81
79
|
end
|
82
80
|
it "should not create role with an error" do
|
83
|
-
post :create, :role
|
81
|
+
post :create, params: { role: { name: 'my role' } }
|
84
82
|
expect(assigns[:role].name).to eq 'my role'
|
85
83
|
expect(assigns[:role].errors[:name]).to eq ['Only letters, numbers, hyphens, underscores and periods are allowed']
|
86
84
|
expect(response).to be_successful
|
@@ -93,13 +91,13 @@ describe RolesController do
|
|
93
91
|
end
|
94
92
|
|
95
93
|
it "should be able to update a role" do
|
96
|
-
put :update, id: role, :
|
94
|
+
put :update, params: { id: role, role: { name: 'my_role' } }
|
97
95
|
expect(response).to redirect_to @routes.url_helpers.edit_role_path(assigns[:role])
|
98
96
|
expect(assigns[:role]).not_to be_new_record
|
99
97
|
expect(assigns[:role].name).to eq 'my_role'
|
100
98
|
end
|
101
99
|
it "should not update role with an error" do
|
102
|
-
put :update, id: role, :
|
100
|
+
put :update, params: { id: role, role: { name: 'my role' } }
|
103
101
|
expect(assigns[:role].name).to eq 'my role'
|
104
102
|
expect(assigns[:role].errors[:name]).to eq ['Only letters, numbers, hyphens, underscores and periods are allowed']
|
105
103
|
expect(response).to be_successful
|
@@ -112,9 +110,8 @@ describe RolesController do
|
|
112
110
|
end
|
113
111
|
|
114
112
|
it "should be able to destroy a role" do
|
115
|
-
delete :destroy, id: role
|
113
|
+
delete :destroy, params: { id: role }
|
116
114
|
expect(response).to redirect_to @routes.url_helpers.roles_path
|
117
115
|
end
|
118
116
|
end
|
119
|
-
|
120
117
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe UserRolesController do
|
4
2
|
let(:ability) do
|
5
3
|
ability = Object.new
|
@@ -13,16 +11,16 @@ describe UserRolesController do
|
|
13
11
|
Role.create(name: 'foo')
|
14
12
|
end
|
15
13
|
|
16
|
-
before(:each) do
|
14
|
+
before(:each) do
|
17
15
|
@routes = Hydra::RoleManagement::Engine.routes
|
18
16
|
end
|
19
17
|
|
20
18
|
describe "with a user who cannot edit users" do
|
21
19
|
it "should not be able to add a user" do
|
22
|
-
expect { post :create, role_id: role, user_key: 'foo@example.com'}.to raise_error CanCan::AccessDenied
|
20
|
+
expect { post :create, params: { role_id: role, user_key: 'foo@example.com' } }.to raise_error CanCan::AccessDenied
|
23
21
|
end
|
24
22
|
it "should not be able to remove a user" do
|
25
|
-
expect { delete :destroy, role_id: role, id: 7}.to raise_error CanCan::AccessDenied
|
23
|
+
expect { delete :destroy, params: { role_id: role, id: 7 } }.to raise_error CanCan::AccessDenied
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
@@ -36,12 +34,12 @@ describe UserRolesController do
|
|
36
34
|
end
|
37
35
|
it "should not be able to add a user that doesn't exist" do
|
38
36
|
expect(User).to receive(:find_by_email).with('foo@example.com').and_return(nil)
|
39
|
-
post :create, role_id: role, user_key: 'foo@example.com'
|
37
|
+
post :create, params: { role_id: role, user_key: 'foo@example.com' }
|
40
38
|
expect(flash[:error]).to eq "Unable to find the user foo@example.com"
|
41
39
|
end
|
42
40
|
it "should be able to add a user" do
|
43
41
|
u = User.create!(email: 'foo@example.com', password: 'password', password_confirmation: 'password')
|
44
|
-
post :create, role_id: role, user_key: 'foo@example.com'
|
42
|
+
post :create, params: { role_id: role, user_key: 'foo@example.com' }
|
45
43
|
expect(role.reload.users).to eq [u]
|
46
44
|
end
|
47
45
|
end
|
@@ -57,10 +55,9 @@ describe UserRolesController do
|
|
57
55
|
end
|
58
56
|
it "should be able to remove a user" do
|
59
57
|
expect(user.roles).to eq [role]
|
60
|
-
delete :destroy, role_id: role, id: user.id
|
58
|
+
delete :destroy, params: { role_id: role, id: user.id }
|
61
59
|
expect(role.reload.users).to eq []
|
62
60
|
end
|
63
61
|
end
|
64
62
|
end
|
65
63
|
end
|
66
|
-
|
data/spec/lib/user_roles_spec.rb
CHANGED
data/spec/models/role_spec.rb
CHANGED
@@ -1,23 +1,21 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe "Routes for role_management" do
|
4
2
|
routes {
|
5
|
-
Hydra::RoleManagement::Engine.routes
|
3
|
+
Hydra::RoleManagement::Engine.routes
|
6
4
|
}
|
7
5
|
context "default" do
|
8
|
-
it "should route index" do
|
6
|
+
it "should route index" do
|
9
7
|
expect(:get => '/roles').to route_to( :controller => "roles", :action => "index")
|
10
8
|
end
|
11
|
-
it "should create roles" do
|
9
|
+
it "should create roles" do
|
12
10
|
expect(:post => '/roles').to route_to( :controller => "roles", :action => "create")
|
13
11
|
end
|
14
|
-
it "should show roles" do
|
12
|
+
it "should show roles" do
|
15
13
|
expect(:get => '/roles/7').to route_to( :controller => "roles", :action => "show", :id => '7')
|
16
14
|
end
|
17
|
-
it "should add users" do
|
15
|
+
it "should add users" do
|
18
16
|
expect(:post => '/roles/7/users').to route_to( :controller => "user_roles", :role_id=>'7', :action => "create")
|
19
17
|
end
|
20
|
-
it "should remove users" do
|
18
|
+
it "should remove users" do
|
21
19
|
expect(:delete => '/roles/7/users/5').to route_to( :controller => "user_roles", :role_id=>'7', :id=>'5', :action => "destroy")
|
22
20
|
end
|
23
21
|
end
|
@@ -36,7 +34,7 @@ describe "Routes for role_management" do
|
|
36
34
|
end
|
37
35
|
|
38
36
|
before(:each) do
|
39
|
-
@routes = Hydra::RoleManagement::Engine.routes
|
37
|
+
@routes = Hydra::RoleManagement::Engine.routes
|
40
38
|
# so we have to do this instead:
|
41
39
|
# engine routes broke in rspec rails 2.12.1, so we had to add this:
|
42
40
|
assertion_instance.instance_variable_set(:@routes, @routes)
|
@@ -47,19 +45,19 @@ describe "Routes for role_management" do
|
|
47
45
|
Rails.application.reload_routes!
|
48
46
|
end
|
49
47
|
|
50
|
-
it "should route index" do
|
48
|
+
it "should route index" do
|
51
49
|
expect(:get => '/admin/groups').to route_to( :controller => "roles", :action => "index")
|
52
50
|
end
|
53
|
-
it "should create roles" do
|
51
|
+
it "should create roles" do
|
54
52
|
expect(:post => '/admin/groups').to route_to( :controller => "roles", :action => "create")
|
55
53
|
end
|
56
|
-
it "should show roles" do
|
54
|
+
it "should show roles" do
|
57
55
|
expect(:get => '/admin/groups/7').to route_to( :controller => "roles", :action => "show", :id => '7')
|
58
56
|
end
|
59
|
-
it "should add users" do
|
57
|
+
it "should add users" do
|
60
58
|
expect(:post => '/admin/groups/7/users').to route_to( :controller => "user_roles", :role_id=>'7', :action => "create")
|
61
59
|
end
|
62
|
-
it "should remove users" do
|
60
|
+
it "should remove users" do
|
63
61
|
expect(:delete => '/admin/groups/7/users/5').to route_to( :controller => "user_roles", :role_id=>'7', :id=>'5', :action => "destroy")
|
64
62
|
end
|
65
63
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,16 +1,22 @@
|
|
1
|
-
require
|
2
|
-
|
1
|
+
require 'coveralls'
|
2
|
+
Coveralls.wear!
|
3
3
|
|
4
|
+
ENV["RAILS_ENV"] ||= 'test'
|
5
|
+
require "bundler/setup"
|
4
6
|
|
5
7
|
require 'engine_cart'
|
6
8
|
EngineCart.load_application!
|
9
|
+
|
10
|
+
require 'rails-controller-testing'
|
7
11
|
require 'rspec/rails'
|
12
|
+
require 'rspec/its'
|
8
13
|
require 'hydra/role_management'
|
9
14
|
|
10
15
|
RSpec.configure do |config|
|
11
16
|
config.use_transactional_fixtures = true
|
12
|
-
config.before(:each, :
|
13
|
-
|
14
|
-
|
17
|
+
config.before(:each, type: :controller) do
|
18
|
+
@routes = Hydra::RoleManagement::Engine.routes
|
19
|
+
end
|
20
|
+
config.include Devise::Test::ControllerHelpers, type: :controller
|
15
21
|
config.infer_spec_type_from_file_location!
|
16
22
|
end
|
@@ -1,30 +1,25 @@
|
|
1
1
|
require 'rails/generators'
|
2
2
|
|
3
3
|
class TestAppGenerator < Rails::Generators::Base
|
4
|
-
source_root
|
4
|
+
source_root "./spec/test_app_templates"
|
5
|
+
|
5
6
|
def add_gems
|
6
7
|
gem 'blacklight', ">= 5.4"
|
7
8
|
end
|
8
|
-
|
9
|
+
|
9
10
|
def run_blacklight_generator
|
10
|
-
say_status("warning", "GENERATING BL", :yellow)
|
11
|
+
say_status("warning", "GENERATING BL", :yellow)
|
11
12
|
|
12
13
|
generate 'blacklight:install', '--devise'
|
13
14
|
end
|
14
15
|
|
15
16
|
def run_cancan_generator
|
16
|
-
say_status("warning", "GENERATING Ability", :yellow)
|
17
|
+
say_status("warning", "GENERATING Ability", :yellow)
|
17
18
|
generate 'cancan:ability'
|
18
19
|
end
|
19
20
|
|
20
21
|
def run_roles_generator
|
21
|
-
say_status("warning", "GENERATING ROLES", :yellow)
|
22
|
-
|
22
|
+
say_status("warning", "GENERATING ROLES", :yellow)
|
23
23
|
generate 'roles', '-f'
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
def copy_rspec_rake_task
|
28
|
-
copy_file "lib/tasks/rspec.rake"
|
29
24
|
end
|
30
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-role-management
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bootstrap_form
|
@@ -95,19 +95,33 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: rails-controller-testing
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: engine_cart
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.0'
|
111
125
|
description: Rails engine to do user roles in an RDBMS for hydra-head
|
112
126
|
email:
|
113
127
|
- justin@curationexperts.com
|
@@ -116,6 +130,7 @@ extensions: []
|
|
116
130
|
extra_rdoc_files: []
|
117
131
|
files:
|
118
132
|
- ".gitignore"
|
133
|
+
- ".rspec"
|
119
134
|
- ".travis.yml"
|
120
135
|
- CONTRIBUTING.md
|
121
136
|
- Gemfile
|
@@ -133,6 +148,8 @@ files:
|
|
133
148
|
- app/views/roles/index.html.erb
|
134
149
|
- app/views/roles/new.html.erb
|
135
150
|
- app/views/roles/show.html.erb
|
151
|
+
- config/locales/role-management.en.yml
|
152
|
+
- config/locales/role-management.es.yml
|
136
153
|
- config/routes.rb
|
137
154
|
- hydra-role-management.gemspec
|
138
155
|
- lib/generators/roles/roles_generator.rb
|
@@ -152,7 +169,7 @@ files:
|
|
152
169
|
- spec/test_app_templates/app/models/solr_document.rb
|
153
170
|
- spec/test_app_templates/config/initializers/hydra_config.rb
|
154
171
|
- spec/test_app_templates/lib/generators/test_app_generator.rb
|
155
|
-
homepage: https://github.com/
|
172
|
+
homepage: https://github.com/samvera/hydra-role-management
|
156
173
|
licenses:
|
157
174
|
- Apache 2.0
|
158
175
|
metadata: {}
|
@@ -172,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
189
|
version: '0'
|
173
190
|
requirements: []
|
174
191
|
rubyforge_project:
|
175
|
-
rubygems_version: 2.
|
192
|
+
rubygems_version: 2.6.13
|
176
193
|
signing_key:
|
177
194
|
specification_version: 4
|
178
195
|
summary: Rails engine to do user roles in an RDBMS for hydra-head
|