forked from vsavkin/DCI-Sample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbids_controller_spec.rb
More file actions
36 lines (29 loc) · 917 Bytes
/
Copy pathbids_controller_spec.rb
File metadata and controls
36 lines (29 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require 'spec_helper'
describe BidsController do
describe "post 'CREATE'" do
let(:current_user){stub}
let(:auction_id){"999"}
let(:request_params){
{auction_id: auction_id}
}
before :each do
controller.should_receive(:current_user).and_return(current_user)
end
context "successful" do
it "should render path to created auction" do
Bidding.should_receive(:make_bid).with(current_user, auction_id).and_return({})
post :create, request_params
response.should redirect_to(auction_path auction_id)
end
end
context "failed" do
let(:errors){["error1"]}
it "should render errors" do
Bidding.should_receive(:make_bid).and_return({errors: errors})
post :create, request_params
response.should redirect_to(auction_path auction_id)
flash[:error].should be_present
end
end
end
end