hydra-role-management 0.0.2 → 0.1.0
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 +4 -4
- data/CONTRIBUTING.md +113 -0
- data/Gemfile +15 -3
- data/README.md +19 -1
- data/Rakefile +7 -12
- data/app/controllers/concerns/hydra/role_management/roles_behavior.rb +33 -3
- data/app/models/concerns/hydra/role_management/legacy_attribute_handling.rb +10 -0
- data/app/models/role.rb +0 -2
- data/app/views/roles/edit.html.erb +28 -0
- data/config/routes.rb +1 -1
- data/hydra-role-management.gemspec +0 -1
- data/lib/generators/roles/roles_generator.rb +33 -6
- data/lib/generators/roles/templates/hydra_role_management_rails3.rb +1 -0
- data/lib/hydra/role_management/version.rb +1 -1
- data/lib/hydra-role-management.rb +1 -2
- data/spec/controllers/roles_controller_spec.rb +60 -6
- data/spec/controllers/user_roles_controller_spec.rb +4 -0
- data/spec/support/gemfile_stub +4 -0
- data/spec/support/lib/generators/test_app_generator.rb +0 -4
- metadata +9 -6
- data/spec/support/Gemfile +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22f2db430fe451abf8fc22c7dcff9d57621e040d
|
4
|
+
data.tar.gz: 10ad448cc0bb012ab357447db7e019b1a00867d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e90822000a247d01e3d4c658b143ec16b7beecd9a3d694351bb41b87d3b2e1afa17c02ee40823d55676f5a0510ee6876b347f6e9d26379ae9c36a8f5fad91e6
|
7
|
+
data.tar.gz: e756a1be05ec233ec7ccfd61597fcbdb964d8b0c5f67a023162e210c998444108c0bc6fef1f24c6a81e718c68e929f9a6a8c351dc405ead4c45072add3b457ac
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
# How to Contribute
|
2
|
+
|
3
|
+
We want your help to make Project Hydra great.
|
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
|
+
|
6
|
+
## Hydra Project Intellectual Property Licensing and Ownership
|
7
|
+
|
8
|
+
All code contributors must have an Individual Contributor License Agreement (iCLA) on file with the Hydra Project Steering Group.
|
9
|
+
If the contributor works for an institution, the institution must have a Corporate Contributor License Agreement (cCLA) on file.
|
10
|
+
|
11
|
+
https://wiki.duraspace.org/display/hydra/Hydra+Project+Intellectual+Property+Licensing+and+Ownership
|
12
|
+
|
13
|
+
You should also add yourself to the `CONTRIBUTORS.md` file in the root of the project.
|
14
|
+
|
15
|
+
## Contribution Tasks
|
16
|
+
|
17
|
+
* Reporting Issues
|
18
|
+
* Making Changes
|
19
|
+
* Submitting Changes
|
20
|
+
* Merging Changes
|
21
|
+
|
22
|
+
### Reporting Issues
|
23
|
+
|
24
|
+
* Make sure you have a [GitHub account](https://github.com/signup/free)
|
25
|
+
* Submit a [Github issue](./issues) by:
|
26
|
+
* Clearly describing the issue
|
27
|
+
* Provide a descriptive summary
|
28
|
+
* Explain the expected behavior
|
29
|
+
* Explain the actual behavior
|
30
|
+
* Provide steps to reproduce the actual behavior
|
31
|
+
|
32
|
+
### Making Changes
|
33
|
+
|
34
|
+
* Fork the repository on GitHub
|
35
|
+
* Create a topic branch from where you want to base your work.
|
36
|
+
* This is usually the master branch.
|
37
|
+
* To quickly create a topic branch based on master; `git branch fix/master/my_contribution master`
|
38
|
+
* Then checkout the new branch with `git checkout fix/master/my_contribution`.
|
39
|
+
* Please avoid working directly on the `master` branch.
|
40
|
+
* You may find the [hub suite of commands](https://github.com/defunkt/hub) helpful
|
41
|
+
* Make commits of logical units.
|
42
|
+
* Your commit should include a high level description of your work in HISTORY.textile
|
43
|
+
* Check for unnecessary whitespace with `git diff --check` before committing.
|
44
|
+
* Make sure your commit messages are [well formed](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
|
45
|
+
* 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)
|
46
|
+
|
47
|
+
```
|
48
|
+
Present tense short summary (50 characters or less)
|
49
|
+
|
50
|
+
More detailed description, if necessary. It should be wrapped to 72
|
51
|
+
characters. Try to be as descriptive as you can, even if you think that
|
52
|
+
the commit content is obvious, it may not be obvious to others. You
|
53
|
+
should add such description also if it's already present in bug tracker,
|
54
|
+
it should not be necessary to visit a webpage to check the history.
|
55
|
+
|
56
|
+
Include Closes #<issue-number> when relavent.
|
57
|
+
|
58
|
+
Description can have multiple paragraphs and you can use code examples
|
59
|
+
inside, just indent it with 4 spaces:
|
60
|
+
|
61
|
+
class PostsController
|
62
|
+
def index
|
63
|
+
respond_with Post.limit(10)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
You can also add bullet points:
|
68
|
+
|
69
|
+
- you can use dashes or asterisks
|
70
|
+
|
71
|
+
- also, try to indent next line of a point for readability, if it's too
|
72
|
+
long to fit in 72 characters
|
73
|
+
```
|
74
|
+
|
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
|
+
### Submitting Changes
|
80
|
+
|
81
|
+
[Detailed Walkthrough of One Pull Request per Commit](http://ndlib.github.io/practices/one-commit-per-pull-request/)
|
82
|
+
|
83
|
+
* Read the article ["Using Pull Requests"](https://help.github.com/articles/using-pull-requests) on GitHub.
|
84
|
+
* Make sure your branch is up to date with its parent branch (i.e. master)
|
85
|
+
* `git checkout master`
|
86
|
+
* `git pull --rebase`
|
87
|
+
* `git checkout <your-branch>`
|
88
|
+
* `git rebase master`
|
89
|
+
* It is likely a good idea to run your tests again.
|
90
|
+
* Squash the commits for your branch into one commit
|
91
|
+
* `git rebase --interactive HEAD~<number-of-commits>` ([See Github help](https://help.github.com/articles/interactive-rebase))
|
92
|
+
* To determine the number of commits on your branch: `git log master..<your-branch> --oneline | wc -l`
|
93
|
+
* 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
|
+
* Push your changes to a topic branch in your fork of the repository.
|
95
|
+
* Submit a pull request from your fork to the project.
|
96
|
+
|
97
|
+
### Merging Changes
|
98
|
+
|
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
|
+
* 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 refactorings_
|
103
|
+
* Does the commit contain more than it should? Are two separate concerns being addressed in one commit?
|
104
|
+
* Did the Travis tests complete successfully?
|
105
|
+
* If you are uncertain, bring other contributors into the conversation by creating a comment that includes their @username.
|
106
|
+
* If you like the pull request, but want others to chime in, create a +1 comment and tag a user.
|
107
|
+
|
108
|
+
# Additional Resources
|
109
|
+
|
110
|
+
* [General GitHub documentation](http://help.github.com/)
|
111
|
+
* [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
|
112
|
+
* [Pro Git](http://git-scm.com/book) is both a free and excellent book about Git.
|
113
|
+
* [A Git Config for Contributing](http://ndlib.github.io/practices/my-typical-per-project-git-config/)
|
data/Gemfile
CHANGED
@@ -1,4 +1,16 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
|
-
#
|
4
|
-
|
3
|
+
# Parameterize the Rails version for flexible testing.
|
4
|
+
rails_version = ENV["RAILS_VERSION"] || "default"
|
5
|
+
rails = case rails_version
|
6
|
+
when "master"
|
7
|
+
{:github => "rails/rails"}
|
8
|
+
when "default"
|
9
|
+
">= 3.2.13"
|
10
|
+
else
|
11
|
+
"~> #{rails_version}"
|
12
|
+
end
|
13
|
+
|
14
|
+
gem "rails", rails
|
15
|
+
gem "rake"
|
16
|
+
gem 'rspec-rails'
|
data/README.md
CHANGED
@@ -1,9 +1,27 @@
|
|
1
1
|
An engine gem to provide a RDBMS backed list of roles and their associated user. This replaces the hydra default role mapper.
|
2
2
|
|
3
|
+
This gem supports both Rails 3 and 4.
|
3
4
|
|
4
|
-
Installing:
|
5
|
+
##Installing:
|
5
6
|
|
6
7
|
* Add: ```gem 'hydra-role-management'``` to your Gemfile and then ```bundle install```
|
7
8
|
* ```rails generate roles```
|
8
9
|
* ```rake db:migrate```
|
10
|
+
* Add the following [cancan](https://github.com/ryanb/cancan) abilities:
|
9
11
|
|
12
|
+
```
|
13
|
+
# app/models/ability.rb
|
14
|
+
if current_user.admin?
|
15
|
+
can [:create, :show, :add_user, :remove_user, :index], Role
|
16
|
+
end
|
17
|
+
```
|
18
|
+
|
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.
|
21
|
+
|
22
|
+
* Install a system javascript runtime or uncomment therubyracer in spec/support/Gemfile
|
23
|
+
* Ensure that the testing app does not exist: ```bundle exec rake clean```
|
24
|
+
* Set Rails version you want to test against. For example:
|
25
|
+
* ```RAILS_VERSION=3.2.13``` or ```RAILS_VERSION=4.0.0```
|
26
|
+
* Ensure that the correct version of Rails is installed: ```bundle update```
|
27
|
+
* Build test app and run tests: ```bundle exec rake spec```
|
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ desc 'Default: run specs.'
|
|
8
8
|
task :default => :spec
|
9
9
|
|
10
10
|
|
11
|
-
task :spec => [:generate] do |t|
|
11
|
+
task :spec => [:clean, :generate] do |t|
|
12
12
|
focused_spec = ENV['SPEC'] ? " SPEC=#{File.join(GEM_ROOT, ENV['SPEC'])}" : ''
|
13
13
|
within_test_app do
|
14
14
|
system "rake myspec#{focused_spec}"
|
@@ -22,23 +22,18 @@ desc "Create the test rails app"
|
|
22
22
|
task :generate do
|
23
23
|
unless File.exists?('spec/internal/Rakefile')
|
24
24
|
puts "Generating rails app"
|
25
|
-
`rails new spec/internal`
|
26
|
-
puts "
|
27
|
-
`
|
25
|
+
`rails _ENV["RAILS_VERSION"]_ new spec/internal`
|
26
|
+
puts "Adding hydra gems to gemfile"
|
27
|
+
`cat spec/support/gemfile_stub >> spec/internal/Gemfile`
|
28
28
|
puts "Copying generator"
|
29
29
|
`cp -r spec/support/lib/generators spec/internal/lib`
|
30
30
|
|
31
31
|
within_test_app do
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
puts `rails generate test_app`
|
36
|
-
|
37
|
-
puts "running migrations"
|
38
|
-
puts `rake db:migrate db:test:prepare`
|
32
|
+
`bundle install`
|
33
|
+
system "rails generate test_app"
|
34
|
+
`rake db:migrate db:test:prepare`
|
39
35
|
end
|
40
36
|
end
|
41
|
-
puts "Running specs"
|
42
37
|
end
|
43
38
|
|
44
39
|
desc "Clean out the test rails app"
|
@@ -11,20 +11,50 @@ module Hydra
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def show
|
14
|
+
redirect_to role_management.edit_role_path(@role) if can? :edit, @role
|
14
15
|
end
|
15
16
|
|
16
17
|
def new
|
17
18
|
end
|
18
19
|
|
20
|
+
def edit
|
21
|
+
end
|
22
|
+
|
19
23
|
def create
|
20
|
-
@role
|
21
|
-
if
|
22
|
-
redirect_to role_management.
|
24
|
+
@role = Role.new(role_params)
|
25
|
+
if @role.save
|
26
|
+
redirect_to role_management.edit_role_path(@role), notice: 'Role was successfully created.'
|
23
27
|
else
|
24
28
|
render action: "new"
|
25
29
|
end
|
26
30
|
end
|
27
31
|
|
32
|
+
def update
|
33
|
+
@role = Role.find(params[:id])
|
34
|
+
if @role.update_attributes(role_params)
|
35
|
+
redirect_to role_management.edit_role_path(@role), notice: 'Role was successfully updated.'
|
36
|
+
else
|
37
|
+
render action: "edit"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def destroy
|
42
|
+
if (@role.destroy)
|
43
|
+
redirect_to role_management.roles_path, notice: 'Role was successfully deleted.'
|
44
|
+
else
|
45
|
+
redirect_to role_management.roles_path
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def role_params
|
52
|
+
if !ActionController.const_defined? :StrongParameters
|
53
|
+
params[:role]
|
54
|
+
else
|
55
|
+
params.require(:role).permit(:name)
|
56
|
+
end
|
57
|
+
end
|
28
58
|
end
|
29
59
|
end
|
30
60
|
end
|
data/app/models/role.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
<h2>Role:</h2>
|
2
|
+
<%= bootstrap_form_for @role, :url=>role_management.role_path(@role) do |f| %>
|
3
|
+
<%= f.text_field :name, :label=> 'Role name' %>
|
4
|
+
<%= f.actions do %>
|
5
|
+
<%= f.submit "Update" %>
|
6
|
+
<% end %>
|
7
|
+
<% end %>
|
8
|
+
<% if can? :destroy, Role %>
|
9
|
+
<%= button_to "Delete", role_management.role_path(@role), :method=>:delete, :class=>'btn btn-danger' %>
|
10
|
+
<% end %>
|
11
|
+
<h3>Accounts:</h3>
|
12
|
+
<ul>
|
13
|
+
<% @role.users.each do |user| %>
|
14
|
+
<li><%= user.user_key %>
|
15
|
+
<% if can? :remove_user, Role %>
|
16
|
+
<%= button_to "Remove User", role_management.role_user_path(@role, user), :method=>:delete, :class=>'btn btn-danger' %>
|
17
|
+
<% end %>
|
18
|
+
</li>
|
19
|
+
<% end %>
|
20
|
+
</ul>
|
21
|
+
<h3>Add a new account:</h3>
|
22
|
+
<%= bootstrap_form_tag role_management.role_users_path(@role) do %>
|
23
|
+
<%= bootstrap_text_field_tag 'user_key', '', :label=>'User' %>
|
24
|
+
<%= bootstrap_actions do %>
|
25
|
+
<%= bootstrap_submit_tag "Add" %>
|
26
|
+
<%= bootstrap_cancel_tag %>
|
27
|
+
<% end %>
|
28
|
+
<% end %>
|
data/config/routes.rb
CHANGED
@@ -37,22 +37,49 @@ This generator makes the following changes to your application:
|
|
37
37
|
# Add behaviors to the user model
|
38
38
|
def inject_user_roles_behavior
|
39
39
|
file_path = "app/models/#{model_name.underscore}.rb"
|
40
|
-
if File.exists?(file_path)
|
41
|
-
|
42
|
-
"\n
|
43
|
-
|
40
|
+
if File.exists?(file_path)
|
41
|
+
if File.read(file_path).match(/include Hydra::User/)
|
42
|
+
code = "\n # Connects this user object to Role-management behaviors. " +
|
43
|
+
"\n include Hydra::RoleManagement::UserRoles\n"
|
44
|
+
inject_into_file file_path, code, { :after => /include Hydra::User/ }
|
45
|
+
else
|
46
|
+
puts " \e[31mFailure\e[0m Hydra::User is not included in #{file_path}. Add 'include Hydra::User' and rerun."
|
47
|
+
end
|
44
48
|
else
|
45
49
|
puts " \e[31mFailure\e[0m hydra-role-management requires a user object. This generators assumes that the model is defined in the file #{file_path}, which does not exist. If you used a different name, please re-run the generator and provide that name as an argument. Such as \b rails -g roles client"
|
46
50
|
end
|
47
51
|
end
|
48
52
|
|
49
|
-
|
50
53
|
# The engine routes have to come after the devise routes so that /users/sign_in will work
|
51
54
|
def inject_routes
|
52
55
|
routing_code = "mount Hydra::RoleManagement::Engine => '/'"
|
53
56
|
sentinel = /devise_for :users/
|
54
57
|
inject_into_file 'config/routes.rb', "\n #{routing_code}\n", { :after => sentinel, :verbose => false }
|
55
|
-
|
58
|
+
end
|
59
|
+
|
60
|
+
# As of 7.23.2013 cancan support for Rails 4 is weak and requires monkey-patching.
|
61
|
+
# More information can be found at https://github.com/ryanb/cancan/issues/835
|
62
|
+
def rails4_application_controller_patch
|
63
|
+
if Rails::VERSION::MAJOR == 4
|
64
|
+
puts "Adding before_filter to application_controller to help Cancan work with Rails 4."
|
65
|
+
file_path = "app/controllers/application_controller.rb"
|
66
|
+
code = "\n before_filter do" +
|
67
|
+
"\n resource = controller_path.singularize.gsub('/', '_').to_sym \n" +
|
68
|
+
' method = "#{resource}_params"'+
|
69
|
+
"\n params[resource] &&= send(method) if respond_to?(method, true)" +
|
70
|
+
"\n end"
|
71
|
+
|
72
|
+
inject_into_file file_path, code, {after: 'class ApplicationController < ActionController::Base'}
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# If this gem is installed under Rails 3, an attr_accessible method is required for the Role model. This
|
77
|
+
# file will be added to config/initializers and the correct code will be added to the model at runtime.
|
78
|
+
def rails3_attr_accessible
|
79
|
+
if !ActionController.const_defined? :StrongParameters
|
80
|
+
puts "Role model will include attr_accessible :name because you are installing this gem in a Rails 3 app."
|
81
|
+
copy_file "hydra_role_management_rails3.rb", "config/initializers/hydra_role_management_rails3.rb"
|
82
|
+
end
|
56
83
|
end
|
57
84
|
|
58
85
|
private
|
@@ -0,0 +1 @@
|
|
1
|
+
Role.send :include, Hydra::RoleManagement::LegacyAttributeHandling
|
@@ -12,17 +12,32 @@ describe RolesController do
|
|
12
12
|
Role.create(name: 'foo')
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
before(:each) do
|
16
|
+
@routes = Hydra::RoleManagement::Engine.routes
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "with a user who cannot edit roles" do
|
20
|
+
it "should not be able to view role index" do
|
18
21
|
lambda { get :index }.should raise_error CanCan::AccessDenied
|
19
22
|
end
|
20
|
-
it "should
|
23
|
+
it "should not be able to view role" do
|
21
24
|
lambda { get :show, id: role }.should raise_error CanCan::AccessDenied
|
22
25
|
end
|
26
|
+
it "should not be able to view new role form" do
|
27
|
+
lambda { get :new }.should raise_error CanCan::AccessDenied
|
28
|
+
end
|
29
|
+
it "should not be able to create a role" do
|
30
|
+
lambda { post :create, :role=>{name: 'my_role'}}.should raise_error CanCan::AccessDenied
|
31
|
+
end
|
32
|
+
it "should not be able to update a role" do
|
33
|
+
lambda { put :update, id: role}.should raise_error CanCan::AccessDenied
|
34
|
+
end
|
35
|
+
it "should not be able to remove a role" do
|
36
|
+
lambda { delete :destroy, id: role}.should raise_error CanCan::AccessDenied
|
37
|
+
end
|
23
38
|
end
|
24
39
|
|
25
|
-
describe "with a user who can
|
40
|
+
describe "with a user who can read roles" do
|
26
41
|
before do
|
27
42
|
ability.can :read, Role
|
28
43
|
end
|
@@ -39,6 +54,15 @@ describe RolesController do
|
|
39
54
|
end
|
40
55
|
end
|
41
56
|
|
57
|
+
describe "with a user who can only update role 'foo'" do
|
58
|
+
it "should be redirected to edit" do
|
59
|
+
ability.can :read, Role
|
60
|
+
ability.can :update, Role, id: role.id
|
61
|
+
get :show, id: role
|
62
|
+
response.should redirect_to @routes.url_helpers.edit_role_path(assigns[:role])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
42
66
|
describe "with a user who can create roles" do
|
43
67
|
before do
|
44
68
|
ability.can :create, Role
|
@@ -51,7 +75,7 @@ describe RolesController do
|
|
51
75
|
|
52
76
|
it "should be able to create a new role" do
|
53
77
|
post :create, :role=>{name: 'my_role'}
|
54
|
-
response.should redirect_to @routes.url_helpers.
|
78
|
+
response.should redirect_to @routes.url_helpers.edit_role_path(assigns[:role])
|
55
79
|
assigns[:role].should_not be_new_record
|
56
80
|
assigns[:role].name.should == 'my_role'
|
57
81
|
end
|
@@ -63,4 +87,34 @@ describe RolesController do
|
|
63
87
|
end
|
64
88
|
end
|
65
89
|
|
90
|
+
describe "with a user who can update roles" do
|
91
|
+
before do
|
92
|
+
ability.can :update, Role
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should be able to update a role" do
|
96
|
+
put :update, id: role, :role=>{name: 'my_role'}
|
97
|
+
response.should redirect_to @routes.url_helpers.edit_role_path(assigns[:role])
|
98
|
+
assigns[:role].should_not be_new_record
|
99
|
+
assigns[:role].name.should == 'my_role'
|
100
|
+
end
|
101
|
+
it "should not update role with an error" do
|
102
|
+
put :update, id: role, :role=>{name: 'my role'}
|
103
|
+
assigns[:role].name.should == 'my role'
|
104
|
+
assigns[:role].errors[:name].should == ['Only letters, numbers, hyphens, underscores and periods are allowed']
|
105
|
+
response.should be_successful
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "with a user who can remove roles" do
|
110
|
+
before do
|
111
|
+
ability.can :destroy, Role
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should be able to destroy a role" do
|
115
|
+
delete :destroy, id: role
|
116
|
+
response.should redirect_to @routes.url_helpers.roles_path
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
66
120
|
end
|
@@ -12,6 +12,10 @@ describe UserRolesController do
|
|
12
12
|
Role.create(name: 'foo')
|
13
13
|
end
|
14
14
|
|
15
|
+
before(:each) do
|
16
|
+
@routes = Hydra::RoleManagement::Engine.routes
|
17
|
+
end
|
18
|
+
|
15
19
|
describe "with a user who cannot edit users" do
|
16
20
|
it "should not be able to add a user" do
|
17
21
|
lambda { post :create, role_id: role, user_key: 'foo@example.com'}.should raise_error CanCan::AccessDenied
|
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.0
|
4
|
+
version: 0.1.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: 2013-
|
11
|
+
date: 2013-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cancan
|
@@ -88,6 +88,7 @@ extensions: []
|
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
90
|
- .gitignore
|
91
|
+
- CONTRIBUTING.md
|
91
92
|
- Gemfile
|
92
93
|
- README.md
|
93
94
|
- Rakefile
|
@@ -95,14 +96,17 @@ files:
|
|
95
96
|
- app/controllers/concerns/hydra/role_management/user_roles_behavior.rb
|
96
97
|
- app/controllers/roles_controller.rb
|
97
98
|
- app/controllers/user_roles_controller.rb
|
99
|
+
- app/models/concerns/hydra/role_management/legacy_attribute_handling.rb
|
98
100
|
- app/models/concerns/hydra/role_management/user_roles.rb
|
99
101
|
- app/models/role.rb
|
102
|
+
- app/views/roles/edit.html.erb
|
100
103
|
- app/views/roles/index.html.erb
|
101
104
|
- app/views/roles/new.html.erb
|
102
105
|
- app/views/roles/show.html.erb
|
103
106
|
- config/routes.rb
|
104
107
|
- hydra-role-management.gemspec
|
105
108
|
- lib/generators/roles/roles_generator.rb
|
109
|
+
- lib/generators/roles/templates/hydra_role_management_rails3.rb
|
106
110
|
- lib/generators/roles/templates/migrations/user_roles.rb
|
107
111
|
- lib/hydra-role-management.rb
|
108
112
|
- lib/hydra/role_management.rb
|
@@ -114,10 +118,10 @@ files:
|
|
114
118
|
- spec/models/role_spec.rb
|
115
119
|
- spec/routing/role_management_routes_spec.rb
|
116
120
|
- spec/spec_helper.rb
|
117
|
-
- spec/support/Gemfile
|
118
121
|
- spec/support/app/models/sample.rb
|
119
122
|
- spec/support/app/models/solr_document.rb
|
120
123
|
- spec/support/config/initializers/hydra_config.rb
|
124
|
+
- spec/support/gemfile_stub
|
121
125
|
- spec/support/lib/generators/test_app_generator.rb
|
122
126
|
- spec/support/lib/tasks/rspec.rake
|
123
127
|
homepage: https://github.com/projecthydra/hydra-role-management
|
@@ -139,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
143
|
version: '0'
|
140
144
|
requirements: []
|
141
145
|
rubyforge_project:
|
142
|
-
rubygems_version: 2.0.
|
146
|
+
rubygems_version: 2.0.3
|
143
147
|
signing_key:
|
144
148
|
specification_version: 4
|
145
149
|
summary: Rails engine to do user roles in an RDBMS for hydra-head
|
@@ -151,10 +155,9 @@ test_files:
|
|
151
155
|
- spec/models/role_spec.rb
|
152
156
|
- spec/routing/role_management_routes_spec.rb
|
153
157
|
- spec/spec_helper.rb
|
154
|
-
- spec/support/Gemfile
|
155
158
|
- spec/support/app/models/sample.rb
|
156
159
|
- spec/support/app/models/solr_document.rb
|
157
160
|
- spec/support/config/initializers/hydra_config.rb
|
161
|
+
- spec/support/gemfile_stub
|
158
162
|
- spec/support/lib/generators/test_app_generator.rb
|
159
163
|
- spec/support/lib/tasks/rspec.rake
|
160
|
-
has_rdoc:
|
data/spec/support/Gemfile
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gem 'rails'
|
4
|
-
|
5
|
-
# Bundle edge Rails instead:
|
6
|
-
# gem 'rails', :git => 'git://github.com/rails/rails.git'
|
7
|
-
|
8
|
-
gem 'sqlite3'
|
9
|
-
gem 'blacklight'
|
10
|
-
gem 'hydra-head'
|
11
|
-
|
12
|
-
|
13
|
-
# Gems used only for assets and not required
|
14
|
-
# in production environments by default.
|
15
|
-
group :assets do
|
16
|
-
gem 'sass-rails', '~> 3.2.3'
|
17
|
-
gem 'coffee-rails', '~> 3.2.1'
|
18
|
-
|
19
|
-
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
|
20
|
-
#gem 'therubyracer', :platforms => :ruby
|
21
|
-
|
22
|
-
gem 'uglifier', '>= 1.0.3'
|
23
|
-
end
|
24
|
-
|
25
|
-
gem 'jquery-rails'
|
26
|
-
|
27
|
-
gem 'hydra-role-management', :path=>'../../'
|
28
|
-
gem 'rspec-rails'
|