hydra-role-management 0.2.0 → 0.2.1

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: 019d9799498cd996b1206a5979af5f312ec82f4e
4
- data.tar.gz: b23a8554dc4227f60635bf6d99ba4c1699130a74
3
+ metadata.gz: b39aee0a1843b7757cddd4c4c92855619c527285
4
+ data.tar.gz: b9c227a38b244b07c2db9f15ca7542630be413f6
5
5
  SHA512:
6
- metadata.gz: ca61c77684d0ac4cd468074afb51e58dce7d5cc271bdd8aa661a4b3102df600a05549926e0d5ae3e1cb5aa1733141ad6d26fe23f5cf6118c3fa35b05a59e3ee3
7
- data.tar.gz: e8bbaf0a58a66214faccf4f50c2ee3b40cad43a12f54fa9900d20cbff3faca4ae77fdf4b9cccbe4dba9ec36c472165bd04e232e03fce356a56ef58031cb7f089
6
+ metadata.gz: 11eeaa238371f79a82e34b222505b3abf2e10066f61831abeb0eff31cb628456bd7a28d1acb7cff48ffed60369fb968e5bb497028930858aaaa64a5607fcd424
7
+ data.tar.gz: 465692f1adcbf16fe1a2f1e1518f3aeb461a87c39e593607e0192b1ee5463e810c77d8fac02d7a5ba81ec6ad9eaf952b96b3f34c44cd8ef7b3335d954d0d1782
@@ -28,7 +28,7 @@ module Hydra
28
28
  protected
29
29
 
30
30
  def find_user
31
- User.send("find_by_#{find_column}".to_sym, params[:user_key])
31
+ ::User.send("find_by_#{find_column}".to_sym, params[:user_key])
32
32
  end
33
33
 
34
34
  def find_column
@@ -1,9 +1,9 @@
1
1
  <h2>Role:</h2>
2
2
  <%= bootstrap_form_for @role, :url=>role_management.role_path(@role) do |f| %>
3
3
  <%= f.text_field :name, :label=> 'Role name' %>
4
- <%= f.actions do %>
4
+
5
5
  <%= f.submit "Update" %>
6
- <% end %>
6
+
7
7
  <% end %>
8
8
  <% if can? :destroy, Role %>
9
9
  <%= button_to "Delete", role_management.role_path(@role), :method=>:delete, :class=>'btn btn-danger' %>
@@ -19,10 +19,8 @@
19
19
  <% end %>
20
20
  </ul>
21
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 %>
22
+ <%= bootstrap_form_tag :url=> role_management.role_users_path(@role) do |f| %>
23
+ <%= f.text_field 'user_key', :label=>'User' %>
24
+ <%= f.submit "Add" %>
25
+ <%= link_to "Cancel", role_management.roles_path, :class => 'btn btn-default' %>
28
26
  <% end %>
@@ -1,5 +1,6 @@
1
1
  <%= bootstrap_form_for @role, :url=>role_management.roles_path do |f| %>
2
2
  <%= f.text_field :name, :label=> 'Role name' %>
3
- <%= f.actions %>
3
+ <%= f.submit "Add" %>
4
+ <%= link_to "Cancel", role_management.roles_path, :class => 'btn btn-default' %>
4
5
  <% end %>
5
6
 
@@ -10,10 +10,8 @@
10
10
  <% end %>
11
11
  </ul>
12
12
  <h3>Add a new account:</h3>
13
- <%= bootstrap_form_tag role_management.role_users_path(@role) do %>
14
- <%= bootstrap_text_field_tag 'user_key', '', :label=>'User' %>
15
- <%= bootstrap_actions do %>
16
- <%= bootstrap_submit_tag "Add" %>
17
- <%= bootstrap_cancel_tag %>
18
- <% end %>
13
+ <%= bootstrap_form_tag url: role_management.role_users_path(@role) do |f| %>
14
+ <%= f.text_field 'user_key', :label=>'User' %>
15
+ <%= f.submit "Add" %>
16
+ <%= link_to "Cancel", role_management.roles_path, :class => 'btn btn-default' %>
19
17
  <% end %>
@@ -1,5 +1,5 @@
1
1
  module Hydra
2
2
  module RoleManagement
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
@@ -4,7 +4,7 @@ describe RolesController do
4
4
  let(:ability) do
5
5
  ability = Object.new
6
6
  ability.extend(CanCan::Ability)
7
- controller.stub(:current_ability).and_return(ability)
7
+ allow(controller).to receive(:current_ability).and_return(ability)
8
8
  ability
9
9
  end
10
10
 
@@ -18,22 +18,22 @@ describe RolesController do
18
18
 
19
19
  describe "with a user who cannot edit roles" do
20
20
  it "should not be able to view role index" do
21
- lambda { get :index }.should raise_error CanCan::AccessDenied
21
+ expect {get :index}.to raise_error CanCan::AccessDenied
22
22
  end
23
23
  it "should not be able to view role" do
24
- lambda { get :show, id: role }.should raise_error CanCan::AccessDenied
24
+ expect {get :show, id: role}.to raise_error CanCan::AccessDenied
25
25
  end
26
26
  it "should not be able to view new role form" do
27
- lambda { get :new }.should raise_error CanCan::AccessDenied
27
+ expect { get :new }.to raise_error CanCan::AccessDenied
28
28
  end
29
29
  it "should not be able to create a role" do
30
- lambda { post :create, :role=>{name: 'my_role'}}.should raise_error CanCan::AccessDenied
30
+ expect { post :create, :role=>{name: 'my_role'}}.to raise_error CanCan::AccessDenied
31
31
  end
32
32
  it "should not be able to update a role" do
33
- lambda { put :update, id: role}.should raise_error CanCan::AccessDenied
33
+ expect { put :update, id: role}.to raise_error CanCan::AccessDenied
34
34
  end
35
35
  it "should not be able to remove a role" do
36
- lambda { delete :destroy, id: role}.should raise_error CanCan::AccessDenied
36
+ expect { delete :destroy, id: role}.to raise_error CanCan::AccessDenied
37
37
  end
38
38
  end
39
39
 
@@ -43,14 +43,14 @@ describe RolesController do
43
43
  end
44
44
  it "should be able to see the list of roles" do
45
45
  get :index
46
- response.should be_successful
47
- assigns[:roles].should == [role]
46
+ expect(response).to be_successful
47
+ expect(assigns[:roles]).to eq [role]
48
48
  end
49
49
 
50
50
  it "should be able to see a single role" do
51
51
  get :show, id: role
52
- response.should be_successful
53
- assigns[:role].should == role
52
+ expect(response).to be_successful
53
+ expect(assigns[:role]).to eq role
54
54
  end
55
55
  end
56
56
 
@@ -59,7 +59,7 @@ describe RolesController do
59
59
  ability.can :read, Role
60
60
  ability.can :update, Role, id: role.id
61
61
  get :show, id: role
62
- response.should redirect_to @routes.url_helpers.edit_role_path(assigns[:role])
62
+ expect(response).to redirect_to @routes.url_helpers.edit_role_path(assigns[:role])
63
63
  end
64
64
  end
65
65
 
@@ -69,21 +69,21 @@ describe RolesController do
69
69
  end
70
70
  it "should be able to make a new role" do
71
71
  get :new
72
- response.should be_successful
73
- assigns[:role].should be_kind_of Role
72
+ expect(response).to be_successful
73
+ expect(assigns[:role]).to be_kind_of Role
74
74
  end
75
75
 
76
76
  it "should be able to create a new role" do
77
77
  post :create, :role=>{name: 'my_role'}
78
- response.should redirect_to @routes.url_helpers.edit_role_path(assigns[:role])
79
- assigns[:role].should_not be_new_record
80
- assigns[:role].name.should == 'my_role'
78
+ expect(response).to redirect_to @routes.url_helpers.edit_role_path(assigns[:role])
79
+ expect(assigns[:role]).not_to be_new_record
80
+ expect(assigns[:role].name).to eq 'my_role'
81
81
  end
82
82
  it "should not create role with an error" do
83
83
  post :create, :role=>{name: 'my role'}
84
- assigns[:role].name.should == 'my role'
85
- assigns[:role].errors[:name].should == ['Only letters, numbers, hyphens, underscores and periods are allowed']
86
- response.should be_successful
84
+ expect(assigns[:role].name).to eq 'my role'
85
+ expect(assigns[:role].errors[:name]).to eq ['Only letters, numbers, hyphens, underscores and periods are allowed']
86
+ expect(response).to be_successful
87
87
  end
88
88
  end
89
89
 
@@ -94,15 +94,15 @@ describe RolesController do
94
94
 
95
95
  it "should be able to update a role" do
96
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'
97
+ expect(response).to redirect_to @routes.url_helpers.edit_role_path(assigns[:role])
98
+ expect(assigns[:role]).not_to be_new_record
99
+ expect(assigns[:role].name).to eq 'my_role'
100
100
  end
101
101
  it "should not update role with an error" do
102
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
103
+ expect(assigns[:role].name).to eq 'my role'
104
+ expect(assigns[:role].errors[:name]).to eq ['Only letters, numbers, hyphens, underscores and periods are allowed']
105
+ expect(response).to be_successful
106
106
  end
107
107
  end
108
108
 
@@ -113,7 +113,7 @@ describe RolesController do
113
113
 
114
114
  it "should be able to destroy a role" do
115
115
  delete :destroy, id: role
116
- response.should redirect_to @routes.url_helpers.roles_path
116
+ expect(response).to redirect_to @routes.url_helpers.roles_path
117
117
  end
118
118
  end
119
119
 
@@ -4,7 +4,8 @@ describe UserRolesController do
4
4
  let(:ability) do
5
5
  ability = Object.new
6
6
  ability.extend(CanCan::Ability)
7
- controller.stub(:current_ability).and_return(ability)
7
+ allow(controller).to receive(:current_ability).and_return(ability)
8
+
8
9
  ability
9
10
  end
10
11
 
@@ -18,10 +19,10 @@ describe UserRolesController do
18
19
 
19
20
  describe "with a user who cannot edit users" do
20
21
  it "should not be able to add a user" do
21
- lambda { post :create, role_id: role, user_key: 'foo@example.com'}.should raise_error CanCan::AccessDenied
22
+ expect { post :create, role_id: role, user_key: 'foo@example.com'}.to raise_error CanCan::AccessDenied
22
23
  end
23
24
  it "should not be able to remove a user" do
24
- lambda { delete :destroy, role_id: role, id: 7}.should raise_error CanCan::AccessDenied
25
+ expect { delete :destroy, role_id: role, id: 7}.to raise_error CanCan::AccessDenied
25
26
  end
26
27
  end
27
28
 
@@ -34,14 +35,14 @@ describe UserRolesController do
34
35
  ability.can :add_user, Role
35
36
  end
36
37
  it "should not be able to add a user that doesn't exist" do
37
- User.should_receive(:find_by_email).with('foo@example.com').and_return(nil)
38
+ expect(User).to receive(:find_by_email).with('foo@example.com').and_return(nil)
38
39
  post :create, role_id: role, user_key: 'foo@example.com'
39
- flash[:error].should == "Unable to find the user foo@example.com"
40
+ expect(flash[:error]).to eq "Unable to find the user foo@example.com"
40
41
  end
41
42
  it "should be able to add a user" do
42
43
  u = User.create!(email: 'foo@example.com', password: 'password', password_confirmation: 'password')
43
44
  post :create, role_id: role, user_key: 'foo@example.com'
44
- role.reload.users.should == [u]
45
+ expect(role.reload.users).to eq [u]
45
46
  end
46
47
  end
47
48
  describe "removing users" do
@@ -55,9 +56,9 @@ describe UserRolesController do
55
56
  u
56
57
  end
57
58
  it "should be able to remove a user" do
58
- user.roles.should == [role]
59
+ expect(user.roles).to eq [role]
59
60
  delete :destroy, role_id: role, id: user.id
60
- role.reload.users.should == []
61
+ expect(role.reload.users).to eq []
61
62
  end
62
63
  end
63
64
  end
@@ -8,7 +8,7 @@ describe Hydra::RoleManagement::UserRoles do
8
8
  end
9
9
 
10
10
  it "should have admin?" do
11
- subject.should_not be_admin
11
+ expect(subject).not_to be_admin
12
12
  end
13
13
 
14
14
  describe "with roles" do
@@ -2,34 +2,34 @@ require 'spec_helper'
2
2
 
3
3
  describe Role do
4
4
  it "should require a name" do
5
- subject.should_not be_valid
5
+ expect(subject).not_to be_valid
6
6
  subject.name = 'foo'
7
- subject.should be_valid
7
+ expect(subject).to be_valid
8
8
  end
9
9
 
10
10
  it "should not allow space in the name" do
11
11
  subject.name = 'foo bar'
12
- subject.should_not be_valid
12
+ expect(subject).not_to be_valid
13
13
  end
14
14
 
15
15
  it "should not allow comma in the name" do
16
16
  subject.name = 'foo,bar'
17
- subject.should_not be_valid
17
+ expect(subject).not_to be_valid
18
18
  end
19
19
 
20
20
  it "should not allow ampersand in the name" do
21
21
  subject.name = 'foo&bar'
22
- subject.should_not be_valid
22
+ expect(subject).not_to be_valid
23
23
  end
24
24
 
25
25
  it "should not allow less-than in the name" do
26
26
  subject.name = 'foo<bar'
27
- subject.should_not be_valid
27
+ expect(subject).not_to be_valid
28
28
  end
29
29
 
30
30
  it "should validate uniqueness" do
31
31
  subject.name ='foo'
32
32
  subject.save!
33
- Role.new(name: 'foo').should_not be_valid
33
+ expect(Role.new(name: 'foo')).not_to be_valid
34
34
  end
35
35
  end
@@ -6,19 +6,19 @@ describe "Routes for role_management" do
6
6
  }
7
7
  context "default" do
8
8
  it "should route index" do
9
- { :get => '/roles' }.should route_to( :controller => "roles", :action => "index")
9
+ expect(:get => '/roles').to route_to( :controller => "roles", :action => "index")
10
10
  end
11
11
  it "should create roles" do
12
- { :post => '/roles' }.should route_to( :controller => "roles", :action => "create")
12
+ expect(:post => '/roles').to route_to( :controller => "roles", :action => "create")
13
13
  end
14
14
  it "should show roles" do
15
- { :get => '/roles/7' }.should route_to( :controller => "roles", :action => "show", :id => '7')
15
+ expect(:get => '/roles/7').to route_to( :controller => "roles", :action => "show", :id => '7')
16
16
  end
17
17
  it "should add users" do
18
- { :post => '/roles/7/users' }.should route_to( :controller => "user_roles", :role_id=>'7', :action => "create")
18
+ expect(:post => '/roles/7/users').to route_to( :controller => "user_roles", :role_id=>'7', :action => "create")
19
19
  end
20
20
  it "should remove users" do
21
- { :delete => '/roles/7/users/5' }.should route_to( :controller => "user_roles", :role_id=>'7', :id=>'5', :action => "destroy")
21
+ expect(:delete => '/roles/7/users/5').to route_to( :controller => "user_roles", :role_id=>'7', :id=>'5', :action => "destroy")
22
22
  end
23
23
  end
24
24
 
@@ -48,19 +48,19 @@ describe "Routes for role_management" do
48
48
  end
49
49
 
50
50
  it "should route index" do
51
- { :get => '/admin/groups' }.should route_to( :controller => "roles", :action => "index")
51
+ expect(:get => '/admin/groups').to route_to( :controller => "roles", :action => "index")
52
52
  end
53
53
  it "should create roles" do
54
- { :post => '/admin/groups' }.should route_to( :controller => "roles", :action => "create")
54
+ expect(:post => '/admin/groups').to route_to( :controller => "roles", :action => "create")
55
55
  end
56
56
  it "should show roles" do
57
- { :get => '/admin/groups/7' }.should route_to( :controller => "roles", :action => "show", :id => '7')
57
+ expect(:get => '/admin/groups/7').to route_to( :controller => "roles", :action => "show", :id => '7')
58
58
  end
59
59
  it "should add users" do
60
- { :post => '/admin/groups/7/users' }.should route_to( :controller => "user_roles", :role_id=>'7', :action => "create")
60
+ expect(:post => '/admin/groups/7/users').to route_to( :controller => "user_roles", :role_id=>'7', :action => "create")
61
61
  end
62
62
  it "should remove users" do
63
- { :delete => '/admin/groups/7/users/5' }.should route_to( :controller => "user_roles", :role_id=>'7', :id=>'5', :action => "destroy")
63
+ expect(:delete => '/admin/groups/7/users/5').to route_to( :controller => "user_roles", :role_id=>'7', :id=>'5', :action => "destroy")
64
64
  end
65
65
  end
66
66
  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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-25 00:00:00.000000000 Z
11
+ date: 2014-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootstrap_form