-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from enjaku4/controller-access-fix
- Loading branch information
Showing
15 changed files
with
133 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module Rabarber | ||
VERSION = "4.1.0" | ||
VERSION = "4.1.1" | ||
end |
24 changes: 24 additions & 0 deletions
24
spec/rabarber/controllers/concerns/authorization/all_access_controller_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "shared_examples" | ||
|
||
RSpec.describe AllAccessController, type: :controller do | ||
let(:user) { User.create! } | ||
|
||
before { allow(controller).to receive(:current_user).and_return(user) } | ||
|
||
describe "when everyone is allowed" do | ||
context "when the user has a role" do | ||
before { user.assign_roles(:maintainer) } | ||
|
||
it_behaves_like "it allows access", get: :quux | ||
end | ||
|
||
context "when the user has no roles" do | ||
it_behaves_like "it allows access", get: :quux | ||
end | ||
|
||
it_behaves_like "it does not allow access when user must have roles", get: :quux | ||
it_behaves_like "it checks permissions integrity", get: :quux | ||
end | ||
end |
36 changes: 36 additions & 0 deletions
36
spec/rabarber/controllers/concerns/authorization/mulitpler_rules_controller_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "shared_examples" | ||
|
||
RSpec.describe MultipleRulesController, type: :controller do | ||
let(:user) { User.create! } | ||
|
||
before { allow(controller).to receive(:current_user).and_return(user) } | ||
|
||
describe "when multitple controller rules are applied" do | ||
context "when one of the user's roles allows access" do | ||
before { user.assign_roles(:maintainer) } | ||
|
||
it_behaves_like "it allows access", delete: :qux | ||
end | ||
|
||
context "when another one of the user's roles allows access" do | ||
before { user.assign_roles(:user, context: Project) } | ||
|
||
it_behaves_like "it allows access", delete: :qux | ||
end | ||
|
||
context "when the user's role does not allow access" do | ||
before { user.assign_roles(:admin) } | ||
|
||
it_behaves_like "it does not allow access", delete: :qux | ||
end | ||
|
||
context "when the user does not have any roles" do | ||
it_behaves_like "it does not allow access", delete: :qux | ||
end | ||
|
||
it_behaves_like "it does not allow access when user must have roles", delete: :qux | ||
it_behaves_like "it checks permissions integrity", delete: :qux | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters