Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add :key in #get_xml, as GovKit may not be configured when the Follow…

…TheMoneyResource class is initialized
  • Loading branch information...
commit 5b56e90f58c135c78448ef091800072cc84dcc96 1 parent f85715a
@jpmckinney jpmckinney authored
View
4 lib/gov_kit/follow_the_money.rb
@@ -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
@@ -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")
View
6 spec/follow_the_money_spec.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.