require 'spec_helper' describe Page do def reset(options = {}) @valid_attributes = { :id => 1, :title => "Page one" } @page.destroy! if @page @page = Page.create!(@valid_attributes.update(options)) RefinerySetting.delete_all RefinerySetting.set(:always_purge_path, '') end before(:each) do reset end context "sweeper" do it "should trigger callback for model" do @page.should_receive(:purge_page) @page.update_attribute(:title, 'Page one still') end it "should purge page url" do ActionController::Base.should_receive(:purge).once.with("/page-one-still") @page.update_attribute(:title, 'Page one still') end context "with 'always_purge_path' set" do before(:each) do RefinerySetting.delete_all RefinerySetting.set(:always_purge_path, '/preview') end it "should purge page url and always_purge_path" do ActionController::Base.should_receive(:purge).with("/page-one-still") ActionController::Base.should_receive(:purge).with("/preview") @page.update_attribute(:title, 'Page one still') end end end end