Commit 20d8151e by Adarsh Pandit

Fix intermittently failing spec

* `fog_spec.rb:328` fails intermittently due to a race condition
* Use [TimeCop][1] gem to freeze time during the spec
* Extract magic number
* Break long line

[1]: https://github.com/travisjeffery/timecop

![TimeCop
Poster](http://www.deconstructingmovies.com/wp-content/uploads/2014/03/timecop-poster.jpg)
parent 266a32a5
...@@ -17,4 +17,5 @@ gem 'pry' ...@@ -17,4 +17,5 @@ gem 'pry'
group :development, :test do group :development, :test do
gem 'mime-types', '~> 1.16' gem 'mime-types', '~> 1.16'
gem 'builder', '~> 3.1.4' gem 'builder', '~> 3.1.4'
gem 'timecop', '~> 0.7.1'
end end
require 'spec_helper' require 'spec_helper'
require 'fog' require 'fog'
require 'timecop'
describe Paperclip::Storage::Fog do describe Paperclip::Storage::Fog do
context "" do context "" do
...@@ -319,11 +320,15 @@ describe Paperclip::Storage::Fog do ...@@ -319,11 +320,15 @@ describe Paperclip::Storage::Fog do
context "generating an expiring url" do context "generating an expiring url" do
it "generates the same url when using Times and Integer offsets" do it "generates the same url when using Times and Integer offsets" do
Timecop.freeze do
offset = 1234
rebuild_model(@options) rebuild_model(@options)
dummy = Dummy.new dummy = Dummy.new
dummy.avatar = StringIO.new('.') dummy.avatar = StringIO.new('.')
assert_equal dummy.avatar.expiring_url(1234), dummy.avatar.expiring_url(Time.now + 1234) assert_equal dummy.avatar.expiring_url(offset),
dummy.avatar.expiring_url(Time.now + offset )
end
end end
it 'matches the default url if there is no assignment' do it 'matches the default url if there is no assignment' do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment