Commit c160ae51 by Jon Yurek

Use a Glue test that doesn't destroy others

For some reason the test in this PR would make all other ones blow up.
For reasons not fully understood at the time of writing, the alternate
spec I'd written doesn't. So, we'll replace that test with this one and
it'll be green.
parent 3f46100f
......@@ -1490,25 +1490,4 @@ describe Paperclip::Attachment do
assert_file_exists(@path)
end
end
context "Non ActiveRecord workflows" do
before do
# temporary take out AR
@ar_bak = Object.send(:remove_const, :ActiveRecord)
end
it "Can include glue without dependency on AR" do
klass = Object.const_set("SomeNonActiveRecordModel", Class.new)
klass.class_eval do
include Paperclip::Glue
end
end
after do
# put back AR
ActiveRecord = @ar_back
end
end
end
# require "spec_helper"
describe Paperclip::Glue do
describe "when ActiveRecord does not exist" do
before do
ActiveRecordSaved = ActiveRecord
Object.send :remove_const, "ActiveRecord"
end
after do
ActiveRecord = ActiveRecordSaved
Object.send :remove_const, "ActiveRecordSaved"
end
it "does not fail" do
NonActiveRecordModel = Class.new
NonActiveRecordModel.include(Paperclip::Glue)
Object.send :remove_const, "NonActiveRecordModel"
end
end
describe "when ActiveRecord does exist" do
before do
if Object.const_defined?("ActiveRecord")
@defined_active_record = false
else
ActiveRecord = :defined
@defined_active_record = true
end
end
after do
if @defined_active_record
Object.send :remove_const, "ActiveRecord"
end
end
it "does not fail" do
Foo = Class.new
Foo.include(Paperclip::Glue)
Object.send :remove_const, "Foo"
end
end
end
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