Skip to content

Commit

Permalink
Implemented specs for importing a parked item
Browse files Browse the repository at this point in the history
  • Loading branch information
baphled committed May 30, 2010
1 parent 7d5786b commit e3cf29b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/parking_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def import
ticket = @resource.ticket(item)
if not LightHouse.create(:ticket_id => item, :title => ticket.title, :body => ticket.original_body)
flash[:error] = "Unable to save tickets"
redirect_to parking_index_path and return
redirect_to tickets_parking_path(:resource => {:id => params[:resource][:id]}) and return
end
end
flash[:notice] = "Parked tickets"
Expand Down
17 changes: 14 additions & 3 deletions spec/controllers/parking_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,20 @@
end

context "imports fail" do
it "should display a flash message"
it "should render the tickets page again"
it "should not save any of the items if one fails"
context "with one resource" do
before(:each) do
LightHouse.stub!(:create).and_return false
post :import, {:lighthouse =>{:ticket_id => ["9", "41"]}, :resource => {:id => 1}}
end

it "should display a flash message" do
flash[:error].should contain "Unable to save tickets"
end

it "should render the tickets page again" do
response.should redirect_to tickets_parking_path(:resource => {:id => 1})
end
end
end
end
end

0 comments on commit e3cf29b

Please sign in to comment.