Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Commit

Permalink
Meetup: warn users about #36
Browse files Browse the repository at this point in the history
  • Loading branch information
Aupajo committed Nov 22, 2019
1 parent 75e6b3e commit 49f41cc
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/almanack/event_source/meetup_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Almanack
module EventSource
class MeetupGroup
def initialize(options = {})
warn "Meetup have disabled support for API keys. Read more at https://github.com/Aupajo/almanack/issues/36"
@request_options = options
@group_properties = {}
end
Expand Down Expand Up @@ -108,11 +109,21 @@ def response
data = JSON.parse(response.body)

if data['problem']
raise MeetupAPIError, data['problem']
raise MeetupAPIError, error_message_from(data)
end

data
end

def error_message_from(data)
message = [data['problem'], data['details']].compact.join(' - ')

if message.include?('not authorized')
message << ' ⚠️ See https://github.com/Aupajo/almanack/issues/36 for more details'
end

message
end
end
end
end
13 changes: 13 additions & 0 deletions spec/event_source/meetup_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ module Almanack::EventSource
end
end
end

it "handles unauthorized errors" do
feed = MeetupGroup.new(group_urlname: 'The-Foundation-Christchurch',
key: 'secrettoken',
connection: Faraday.new)

VCR.use_cassette('meetup-unauthorized') do
from = Time.now
to = from + 30 * 24 * 60 * 60
expect { feed.events_between(from..to) }
.to raise_error(%r{https://github.com/Aupajo/almanack/issues/36})
end
end
end

describe "#serialized_between" do
Expand Down
60 changes: 60 additions & 0 deletions spec/fixtures/responses/meetup-unauthorized.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 49f41cc

Please sign in to comment.