<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>spec/responses/Official.get_by_office_state.12.CO.js</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -86,7 +86,7 @@ module VoteSmart
       if response.class == Net::HTTPOK
         result = JSON.parse(response.body)
       else
-        raise RequestFailed.new(&quot;Request was not OK: #{response.class}: #{response.body}&quot;)
+        raise RequestFailed.new(&quot;Request was not OK: #{response.class}: #{url} #{response.body}&quot;)
       end
       
     end # self.get_json_data</diff>
      <filename>lib/vote_smart/common.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@ module VoteSmart
     attr_accessor :id, :first_name, :nick_name, :middle_name, :last_name, :suffix, :title,
                   :election_parties, :office_parties, :district_id, :district_name, :state_id
     
-    attr_accessor :district, :office
+    attr_accessor :district, :office, :office_id
     
     set_attribute_map &quot;candidateId&quot; =&gt; :id, &quot;firstName&quot; =&gt; :first_name, &quot;nickName&quot; =&gt; :nick_name,
                       &quot;middleName&quot; =&gt; :middle_name, &quot;lastName&quot; =&gt; :last_name, &quot;suffix&quot; =&gt; :suffix,
@@ -20,6 +20,10 @@ module VoteSmart
       &quot;Official: &quot; + [title, first_name, last_name].compact.join(' ')
     end
     
+    def office_id
+      @office_id || (office.id if office)
+    end
+    
     def self.find_by_district district
       official = find_by_district_id district.id
       official.district = district if official
@@ -33,13 +37,18 @@ module VoteSmart
     
     def self.find_by_office_id_and_state_id office_id, state_id
       response = response_child(get_by_office_state(office_id, state_id), &quot;candidateList&quot;, &quot;candidate&quot;)
-      Official.new(response) unless response.empty?
+      official = Official.new(response) unless response.empty?
+      official.office_id = office_id if official
+      official.state_id ||= state_id if official
+      official
     end
     
     
     
     def self.find_all_by_address address, city, state, zip
       placemark = Geocoding.get(&quot;#{address} #{city}, #{state} #{zip}&quot;).first
+      state ||= placemark.administrative_area
+      
       placemark ? find_all_by_state_and_latitude_and_longitude(state, placemark.latitude, placemark.longitude) : []
     end
 </diff>
      <filename>lib/vote_smart/official.rb</filename>
    </modified>
    <modified>
      <diff>@@ -19,11 +19,18 @@ def gem_available_on_server?
   }
 end
 
+def gem_is_in_specfile?
+  fetcher = Gem::SpecFetcher.new
+  specs = fetcher.load_specs(URI.parse('http://gems.github.com/'), 'specs')
+  specs.any?{|(name, spec)| name == @gem_name and spec.version.to_s == @gem_spec.version.to_s }
+end
+
+
 is_built = false
 
 while not is_built
   
-  if gem_available_on_server?
+  if gem_available_on_server? &amp;&amp; gem_is_in_specfile?
     is_built = true
     system &quot;say 'gem is built'&quot;
   else</diff>
      <filename>script/is_gem_built</filename>
    </modified>
    <modified>
      <diff>@@ -9,7 +9,7 @@ module VoteSmart
         Official.find_by_district_id(&quot;20451&quot;)
       end
       
-      it_should_find :item =&gt; {:last_name =&gt; &quot;Isakson&quot;, :id =&gt; &quot;1721&quot;}
+      it_should_find :item =&gt; {:last_name =&gt; &quot;Isakson&quot;, :id =&gt; &quot;1721&quot;, :district_id =&gt; &quot;20451&quot;}
     end
     
     describe &quot;multiple offices&quot; do
@@ -33,6 +33,16 @@ module VoteSmart
       it_should_find :count =&gt; 1, :first =&gt; {:address =&gt; {:type =&gt; &quot;Capitol&quot;}}
     end
     
+    describe &quot;find_by_office_id_and_state_id&quot; do
+      
+      def do_find
+        Official.find_by_office_id_and_state_id(&quot;12&quot;, &quot;CO&quot;)
+      end
+      
+      it_should_find :item =&gt; {:last_name =&gt; &quot;Suthers&quot;, :id =&gt; &quot;29799&quot;, :office_id =&gt; &quot;12&quot;, :state_id =&gt; &quot;CO&quot;}
+      
+    end
+    
     describe &quot;find by address&quot; do
       
       before :each do</diff>
      <filename>spec/vote_smart/official_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -55,7 +55,9 @@ namespace :spec do
     
     # save_json VoteSmart::Official, :get_by_district, &quot;21397&quot;
     
-    save_json VoteSmart::Address, :get_office, &quot;106446&quot;
+    # save_json VoteSmart::Address, :get_office, &quot;106446&quot;
+    
+    save_json VoteSmart::Official, :get_by_office_state, &quot;12&quot;, &quot;CO&quot;
   end
   
 end
\ No newline at end of file</diff>
      <filename>tasks/spec_json.rake</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>6034aa817c50c7b7eb66dbb4a74c4314f9b3f3e0</id>
    </parent>
  </parents>
  <author>
    <name>Dan Cunning</name>
    <email>dancunning@gmail.com</email>
  </author>
  <url>http://github.com/netroots/ruby-votesmart/commit/53a253a7a364b4df3a7c105591f50a6d889df7d9</url>
  <id>53a253a7a364b4df3a7c105591f50a6d889df7d9</id>
  <committed-date>2009-02-17T14:45:29-08:00</committed-date>
  <authored-date>2009-02-17T14:45:29-08:00</authored-date>
  <message>relationship caching.</message>
  <tree>f5ef7f9787ef050d84490d7c02d7567b8c7983ee</tree>
  <committer>
    <name>Dan Cunning</name>
    <email>dancunning@gmail.com</email>
  </committer>
</commit>
