Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/rails/auth/acl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ def self.from_yaml(yaml, **args)
# @param [Hash] :matchers predicate matchers for use with this ACL
#
def initialize(acl, matchers: {})
raise TypeError, "expected Array for acl, got #{acl.class}" unless acl.is_a?(Array)

@resources = []

acl.each_with_index do |entry|
acl.each do |entry|
raise TypeError, "expected Hash for acl entry, got #{entry.class}" unless entry.is_a?(Hash)

resources = entry["resources"]
raise ParseError, "no 'resources' key present in entry: #{entry.inspect}" unless resources

Expand Down
6 changes: 6 additions & 0 deletions spec/rails/auth/acl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
)
end

describe "#initialize" do
it "raises TypeError if given a non-Array ACL type" do
expect { described_class.new(:bogus) }.to raise_error(TypeError)
end
end

describe "#match" do
it "matches routes against the ACL" do
expect(example_acl.match(env_for(:get, "/"))).to eq true
Expand Down