Skip to content

Commit

Permalink
Fix error reported when verb has no id
Browse files Browse the repository at this point in the history
  • Loading branch information
gtrias committed Sep 17, 2024
1 parent e6cc4e4 commit 6918043
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/public/verb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def dump

sig { params(spec: T.untyped).returns(Verb) }
def self.load(spec)
id = spec['id'].to_sym
id = spec['id']&.to_sym
raise ArgumentError, "Missing verb ID: #{id}" if id.nil?

dto = spec['dto']
Expand Down
9 changes: 9 additions & 0 deletions spec/public/resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@

it { expect(subject).to be_a(described_class) }

context 'when verb has no id' do
let(:dump) { resource.dump }
let(:spec) do
resource.dump.tap { |s| s['verbs']['copy'].delete('id') }
end

it { expect { subject }.to raise_error(ArgumentError) }
end

describe 'paginateable' do
context 'when the paginateable property is not provided' do
it 'is true by default' do
Expand Down

0 comments on commit 6918043

Please sign in to comment.