Skip to content

Commit

Permalink
Fix Action#ticket and add specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ppostma committed Aug 13, 2024
1 parent 950bcda commit c8293ac
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions lib/kentaa/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
require_relative 'api/resources/site'
require_relative 'api/resources/sites'
require_relative 'api/resources/team'
require_relative 'api/resources/ticket'
require_relative 'api/resources/theme'
require_relative 'api/resources/user'
require_relative 'api/resources/users'
Expand Down
2 changes: 1 addition & 1 deletion lib/kentaa/api/resources/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def registration_fee
end

def ticket
@location ||= Kentaa::Api::Resources::Ticket.new(data[:ticket]) if data[:ticket]
@ticket ||= Kentaa::Api::Resources::Ticket.new(data[:ticket]) if data[:ticket]
end

def location
Expand Down
7 changes: 7 additions & 0 deletions spec/fixtures/responses/action.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
"amount": "25.0",
"title": "Sign up fee"
},
"ticket": {
"id": 1,
"created_at": "2024-07-17T21:14:11Z",
"updated_at": "2024-07-17T21:14:11Z",
"ticket_number": "3OJHY9RU5D",
"ticket_url": "https://demo1.kentaa.nl/admin/acties/1/download-ticket.pdf"
},
"photos": [
{
"id": 2,
Expand Down
12 changes: 8 additions & 4 deletions spec/kentaa/api/resources/action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,19 @@

describe '#registration_fee' do
it 'returns the related registration fee' do
expect(response.registration_fee).to be_a(Kentaa::Api::Resources::RegistrationFee)
expect(response.registration_fee.amount).to eq(BigDecimal('25.0'))
expect(response.registration_fee.title).to eq('Sign up fee')
registration_fee = response.registration_fee
expect(registration_fee).to be_a(Kentaa::Api::Resources::RegistrationFee)
expect(registration_fee.amount).to eq(BigDecimal('25.0'))
expect(registration_fee.title).to eq('Sign up fee')
end
end

describe '#ticket' do
it 'returns the related ticket' do
expect(response.ticket).to be_nil
ticket = response.ticket
expect(ticket).to be_a(Kentaa::Api::Resources::Ticket)
expect(ticket.ticket_number).to eq('3OJHY9RU5D')
expect(ticket.ticket_url).to eq('https://demo1.kentaa.nl/admin/acties/1/download-ticket.pdf')
end
end

Expand Down

0 comments on commit c8293ac

Please sign in to comment.