Skip to content

Commit

Permalink
Attempt to recreate bug cited by @monfresh in artsy#53
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Macreery committed Sep 17, 2013
1 parent d609054 commit 9c87cf4
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
38 changes: 38 additions & 0 deletions spec/integration/grape_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,48 @@ class TestGrapeApp < Grape::API
{ :meaning_of_life => 42 }.to_json
end
end

get "/mongers" do
garner.options({ :expires_in => 5.minutes }) do
Monger.all
end
end
end

TestGrapeApp.new
end

it_behaves_like "Rack::ConditionalGet server"

context "caching modified classes/objects" do
include Rack::Test::Methods

before(:each) do
@object = Monger.create!({ :name => "M1" })
end

it "does not raise error when underlying classes are changed" do
json = Monger.all.to_json
browser = Rack::Test::Session.new(TestGrapeApp.new)
browser.get "/mongers"
browser.last_response.should be_successful
browser.last_response.body.should == json

TestGrapeApp.reset!
class TestGrapeApp < Grape::API
helpers Garner::Mixins::Rack

format :json

get "/mongers" do
Monger.all
end
end

browser = Rack::Test::Session.new(TestGrapeApp.new)
browser.get "/mongers"
browser.last_response.should be_successful
browser.last_response.body.should == json
end
end
end
25 changes: 25 additions & 0 deletions spec/integration/mongoid_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,31 @@
end
end
end

context "caching modified classes/objects" do
before(:each) do
@object = Monger.create!({ :name => "M1" })
end

let(:cached_object_fetcher) do
lambda do
@app.garner.options({ :expires_in => 5.minutes }) do
Monger.all.as_json
end
end
end

it "does not raise error when underlying classes are changed" do
json = Monger.all.as_json
cached_object_fetcher.call.should == json

class Monger
field :foo, :type => Boolean
end

cached_object_fetcher.call.should == json
end
end
end
end
end
Expand Down

0 comments on commit 9c87cf4

Please sign in to comment.