Tests for regular_url
parent
9535fd46b3
commit
3efb85ec92
|
@ -24,4 +24,13 @@ describe Image do
|
|||
expect(url).to include("/images/attachments/000/000/123/x640/foo.jpg?")
|
||||
expect(url).to include(now.to_i.to_s)
|
||||
end
|
||||
|
||||
it "generates a URL when BUCKET is set" do
|
||||
const_reassign(Image, :BUCKET, "foo") do
|
||||
i = Image.new
|
||||
expect(i).to receive(:attachment).and_return(Struct.new(:key).new("bar"))
|
||||
url = i.regular_url
|
||||
expect(url).to eq("https://storage.cloud.google.com/foo/bar")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -117,8 +117,14 @@ end
|
|||
# Reassign constants without getting a bunch of warnings to STDOUT.
|
||||
# This is just for testing purposes, so NBD.
|
||||
def const_reassign(target, const, value)
|
||||
b4 = target.const_get(const)
|
||||
target.send(:remove_const, const)
|
||||
target.const_set(const, value)
|
||||
if block_given?
|
||||
yield
|
||||
target.send(:remove_const, const)
|
||||
target.const_set(const, b4)
|
||||
end
|
||||
end
|
||||
|
||||
class StubResp
|
||||
|
|
Loading…
Reference in New Issue