Skip to content

Commit

Permalink
add :key in #get_xml, as GovKit may not be configured when the Follow…
Browse files Browse the repository at this point in the history
…TheMoneyResource class is initialized
  • Loading branch information
James McKinney committed Nov 7, 2012
1 parent f85715a commit 5b56e90
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/gov_kit/follow_the_money.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module GovKit
#
# For the details on the FollowTheMoney queries, see {http://www.followthemoney.org/services/methods.phtml the FollowTheMoney API documentation}.
class FollowTheMoneyResource < Resource
default_params :key => GovKit::configuration.ftm_apikey
base_uri GovKit::configuration.ftm_base_url
format :xml

Expand All @@ -20,6 +19,9 @@ class FollowTheMoneyResource < Resource
# doc = get_xml("/base_level.industries.list.php", :query => {:page => page_num})
#
def self.get_xml(path, options)
options[:query] ||= {}
options[:query][:key] = GovKit::configuration.ftm_apikey

doc = Nokogiri::XML(get(path, options).body)

e = doc.search("//error")
Expand Down
6 changes: 6 additions & 0 deletions spec/follow_the_money_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@ module GovKit::FollowTheMoney
end

it "should raise NotAuthorized if the api key is not valid" do
api_key = GovKit.configuration.ftm_apikey

GovKit.configuration.ftm_apikey = nil

lambda do
@contribution = Contribution.find(0)
end.should raise_error(GovKit::NotAuthorized)

@contribution.should be_nil

GovKit.configuration.ftm_apikey = api_key
end

describe Business do
Expand Down

0 comments on commit 5b56e90

Please sign in to comment.