Created
October 18, 2012 14:30
-
-
Save kalorz/3912242 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test 'should get daily offers' do | |
Timecop.freeze do | |
offer1 = create(:offer, :promoted, :long_description, partner: create(:partner), expires_at: 2.days.since) | |
offer2 = create(:offer, partner: create(:partner, :virtual), promoted_since: 3.days.ago, expires_at: 10.days.since, created_at: 1.second.since) | |
user = create(:user, stashed_offers: [offer1]) | |
create(:user, stashed_offers: [offer1, offer2]) | |
authenticate user | |
get :daily | |
assert_response :ok | |
assert_equal({ | |
'status' => 'ok', | |
'offers' => [ | |
{ | |
'id' => offer2.id, | |
'partner_id' => offer2.partner.id, | |
'icon_url' => '/system/offers/icons/original/100x100.png', | |
'name' => '50% off second item', | |
'summary' => 'Buy any product at our store, get second 50% cheaper!', | |
'expires_at' => 10.days.since.utc.to_i, | |
'expires_in' => 10 * (24 * 3600), | |
'stashed' => false | |
}, | |
{ | |
'id' => offer1.id, | |
'partner_id' => offer1.partner.id, | |
'icon_url' => '/system/offers/icons/original/100x100.png', | |
'name' => '50% off second item', | |
'summary' => 'This is very very long so that we can check whether it will be properly cut at 140 characters, so that you should see ellipsis here,...', | |
'expires_at' => 2.days.since.utc.to_i, | |
'expires_in' => 2 * (24 * 3600), | |
'stashed' => true | |
} | |
] | |
}, json_response) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Failure: | |
test_should_get_daily_offers(Api::OffersControllerTest) [test/functional/api/offers_controller_test.rb:134]: | |
<{"status"=>"ok", | |
"offers"=> | |
[{"id"=>2, | |
"partner_id"=>2, | |
"icon_url"=>"/system/offers/icons/original/100x100.png", | |
"name"=>"50% off second item", | |
"summary"=>"Buy any product at our store, get second 50% cheaper!", | |
"expires_at"=>1351437987, | |
"expires_in"=>900000, | |
"stashed"=>false}, | |
{"id"=>1, | |
"partner_id"=>1, | |
"icon_url"=>"/system/offers/icons/original/100x100.png", | |
"name"=>"50% off second item", | |
"summary"=> | |
"This is very very long so that we can check whether it will be properly cut at 140 characters, so that you should see ellipsis here,...", | |
"expires_at"=>1350743187, | |
"expires_in"=>172800, | |
"stashed"=>true}]}> expected but was | |
<{"offers"=> | |
[{"id"=>2, | |
"partner_id"=>2, | |
"icon_url"=>"/system/offers/icons/original/100x100.png", | |
"name"=>"50% off second item", | |
"summary"=>"Buy any product at our store, get second 50% cheaper!", | |
"expires_at"=>1351437987, | |
"expires_in"=>867600, | |
"stashed"=>false}, | |
{"id"=>1, | |
"partner_id"=>1, | |
"icon_url"=>"/system/offers/icons/original/100x100.png", | |
"name"=>"50% off second item", | |
"summary"=> | |
"This is very very long so that we can check whether it will be properly cut at 140 characters, so that you should see ellipsis here,...", | |
"expires_at"=>1350743187, | |
"expires_in"=>172800, | |
"stashed"=>true}], | |
"status"=>"ok"}>. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment