From 135039dd5be0096835836f6e23083f44a04f0aef Mon Sep 17 00:00:00 2001 From: Marnen Laibow-Koser Date: Fri, 23 Oct 2009 02:09:47 -0400 Subject: [PATCH] Rewrite app for new structure. All tests pass, but we've exposed a couple of bugs. [#44] --- app/views/events/new.html.haml | 2 +- app/views/users/new.html.haml | 2 +- spec/blueprints.rb | 4 ++-- spec/models/event_spec.rb | 6 +++--- spec/models/user_spec.rb | 6 +++--- spec/views/calendars/users.html.haml_spec.rb | 2 +- spec/views/events/map.html.haml_spec.rb | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/views/events/new.html.haml b/app/views/events/new.html.haml index 2029664a..8d42fda0 100644 --- a/app/views/events/new.html.haml +++ b/app/views/events/new.html.haml @@ -38,7 +38,7 @@ %tr %th&= _("State") %td - = f.collection_select :state_id, State.find(:all), :id, :name + = f.collection_select :state_id, Acts::Addressed::State.find(:all), :id, :name = _(error_message_on :event, :state) %tr %th&= _("Zip") diff --git a/app/views/users/new.html.haml b/app/views/users/new.html.haml index 6a3b4d38..7b4a023b 100644 --- a/app/views/users/new.html.haml +++ b/app/views/users/new.html.haml @@ -40,7 +40,7 @@ %td= f.text_field :city %tr %th&= _("State") - %td= f.collection_select(:state_id, State.find(:all, :order => :name), :id, :name, :include_blank => true) + %td= f.collection_select(:state_id, Acts::Addressed::State.find(:all, :order => :name), :id, :name, :include_blank => true) %tr %th&= _("ZIP code") %td= f.text_field :zip diff --git a/spec/blueprints.rb b/spec/blueprints.rb index f652b722..dc68461e 100644 --- a/spec/blueprints.rb +++ b/spec/blueprints.rb @@ -17,13 +17,13 @@ created_by {User.make} end -State.blueprint do +Acts::Addressed::State.blueprint do country name {Sham.generic_name} code end -Country.blueprint do +Acts::Addressed::Country.blueprint do name {Sham.generic_name} code end diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index a5835d5a..1925862e 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -42,7 +42,7 @@ it "should have a country property referred through state" do event = Event.new - event.state = State.new + event.state = Acts::Addressed::State.new event.country.should == event.state.country end @@ -55,10 +55,10 @@ aggr = Event.reflect_on_aggregation(:address) aggr.should_not be_nil aggr.options[:mapping].should == [%w(street street), %w(street2 street2), %w(city city), %w(state_id state), %w(zip zip), %w(coords coords)] - state = State.make(:code => 'NY', :country => Country.make(:code => 'US')) + state = Acts::Addressed::State.make opts = {:street => '123 Main Street', :street2 => '1st floor', :city => 'Anytown', :zip => 12345, :state => state} e = Event.new(opts) - e.address.should == Address.new(opts) + e.address.should == Acts::Addressed::Address.new(opts) end it "should have a deleted property" do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index a4fdb403..b3384b84 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -38,10 +38,10 @@ aggr = User.reflect_on_aggregation(:address) aggr.should_not be_nil aggr.options[:mapping].should == [%w(street street), %w(street2 street2), %w(city city), %w(state_id state), %w(zip zip), %w(coords coords)] - state = State.make(:code => 'NY', :country => Country.make(:code => 'US')) + state = Acts::Addressed::State.make opts = {:street => '123 Main Street', :street2 => '1st floor', :city => 'Anytown', :zip => 12345, :state => state} u = User.new(opts) - u.address.should == Address.new(opts) + u.address.should == Acts::Addressed::Address.new(opts) end it "should have a writable flag controlling display of personal information on contact list" do @@ -51,7 +51,7 @@ end it "should have country referred through state" do - state = State.make + state = Acts::Addressed::State.make user = User.new user.should respond_to(:country) user.state = state diff --git a/spec/views/calendars/users.html.haml_spec.rb b/spec/views/calendars/users.html.haml_spec.rb index 0521ee2e..89e84f75 100644 --- a/spec/views/calendars/users.html.haml_spec.rb +++ b/spec/views/calendars/users.html.haml_spec.rb @@ -21,7 +21,7 @@ @all_users.each do |u| p = u.permissions[0] u.permissions.stub!(:find_by_calendar_id).and_return(p) - u.stub!(:state).and_return(mock_model(State, :null_object => true)) + u.stub!(:state).and_return Acts::Addressed::State.make u.stub!(:street).and_return('123 Main Street') u.stub!(:street2).and_return('x') u.stub!(:city).and_return('Somewhere') diff --git a/spec/views/events/map.html.haml_spec.rb b/spec/views/events/map.html.haml_spec.rb index b4349acf..8afbbb02 100644 --- a/spec/views/events/map.html.haml_spec.rb +++ b/spec/views/events/map.html.haml_spec.rb @@ -6,7 +6,7 @@ end it "should render the map in @map" do - address = Address.new + address = Acts::Addressed::Address.new address.should_receive(:to_s).with(:geo).and_return('Arbitrary Address, Somewhere, NY, US') User.stub!(:current_user).and_return(mock_model(User, :address => address)) render 'events/map'