test/unit/test_modifications.rb in spontaneous-0.2.0.alpha7 vs test/unit/test_modifications.rb in spontaneous-0.2.0.beta1

- old
+ new

@@ -19,15 +19,15 @@ stub_time(@now) # DB.logger = Logger.new($stdout) Content.delete - class Page < Spontaneous::Page + class Page < ::Page field :title, :string, :default => "New Page" box :things end - class Piece < Spontaneous::Piece + class Piece < ::Piece box :things end @root = Page.create(:uid => "root") count = 0 @@ -77,11 +77,11 @@ end should "update modification date of path when page visibility is changed" do now = @now + 100 stub_time(now) - c = Page.first + c = Page.uid("0") (c.modified_at.to_i - @now.to_i).abs.should <= 1 c.toggle_visibility! (c.modified_at - now).abs.should <= 1 end @@ -134,11 +134,11 @@ content.modified_at.to_i.should == @now.to_i + 3600 page.reload page.modified_at.to_i.should == @now.to_i + 3600 end - should "not update the parent page's timestamp on addition of a child page" do + should "not update the parent page's timestamp on addition of a child page yyyy" do stub_time(@now+1000) page = Page.first :uid => "0" page.things << Page.new page.save.reload page.modified_at.to_i.should == @now.to_i @@ -217,11 +217,11 @@ page.reload page.pending_modifications.length.should == 1 mods = page.pending_modifications(:slug) mods.length.should == 1 mod = mods.first - mod.must_be_instance_of Spontaneous::Plugins::Modifications::SlugModification + mod.must_be_instance_of Spontaneous::Model::Core::Modifications::SlugModification mod.old_value.should == old_slug mod.new_value.should == "changed" mod.created_at.to_i.should == @now.to_i + 3600 end @@ -354,11 +354,11 @@ setup do @initial_revision = 1 @final_revision = 2 Content.delete_revision(@initial_revision) rescue nil Content.delete_revision(@final_revision) rescue nil - S::Content.publish(@initial_revision) + ::Content.publish(@initial_revision) end teardown do Content.delete_revision(@initial_revision) rescue nil Content.delete_revision(@final_revision) rescue nil @@ -368,15 +368,15 @@ should "act on path change modifications" do page = Page.first :uid => "1" old_slug = page.slug page.slug = "changed" page.save - S::Content.publish(@final_revision, [page.id]) - S::Content.with_revision(@final_revision) do + ::Content.publish(@final_revision, [page.id]) + ::Content.with_revision(@final_revision) do %w(1 1.1.1).each do |uid| published_page = Page.first :uid => uid - S::Content.with_editable do + ::Content.with_editable do editable_page = Page.first :uid => uid published_page.path.should == editable_page.path end end end @@ -394,12 +394,12 @@ child_page = Page.first :uid => "1.0.0" old_slug = child_page.slug child_page.slug = "changed-too" child_page.save - S::Content.publish(@final_revision, [page.id]) - S::Content.with_revision(@final_revision) do + ::Content.publish(@final_revision, [page.id]) + ::Content.with_revision(@final_revision) do published = Page.first :uid => "1.0.0" published.path.should == "/changed/#{old_slug}" end end @@ -415,26 +415,26 @@ child_page = Page.first :uid => "1.0.0" child_page.slug = "changed-too" child_page.save - S::Content.publish(@final_revision, [child_page.id]) - S::Content.with_revision(@final_revision) do + ::Content.publish(@final_revision, [child_page.id]) + ::Content.with_revision(@final_revision) do published = Page.first :uid => "1.0.0" published.path.should == "/#{old_slug}/changed-too" end end should "act on visibility modifications" do page = Page.first :uid => "1" page.hide! - S::Content.publish(@final_revision, [page.id]) - S::Content.with_revision(@final_revision) do + ::Content.publish(@final_revision, [page.id]) + ::Content.with_revision(@final_revision) do %w(1 1.1.1).each do |uid| published_page = Page.first :uid => uid - S::Content.with_editable do + ::Content.with_editable do editable_page = Page.first :uid => uid published_page.hidden?.should == editable_page.hidden? end end end @@ -446,13 +446,13 @@ child_page = Page.new :uid => "child" page.things << child_page page.save - S::Content.publish(@final_revision, [child_page.id]) + ::Content.publish(@final_revision, [child_page.id]) - S::Content.with_revision(@final_revision) do + ::Content.with_revision(@final_revision) do published = Page.first :uid => "1.0.0" published.visible?.should be_true published = Page.first :uid => "child" published.visible?.should be_true end @@ -464,13 +464,13 @@ child_page = Page.new :uid => "child" page.things << child_page page.save - S::Content.publish(@final_revision, [page.id, child_page.id]) + ::Content.publish(@final_revision, [page.id, child_page.id]) - S::Content.with_revision(@final_revision) do + ::Content.with_revision(@final_revision) do published = Page.first :uid => "child" published.visible?.should be_false end end @@ -482,13 +482,13 @@ child_page = Page.first :uid => "1.0.0" child_page.slug = "changed-too" child_page.save - S::Content.publish(@final_revision, [child_page.id]) + ::Content.publish(@final_revision, [child_page.id]) - S::Content.with_revision(@final_revision) do + ::Content.with_revision(@final_revision) do published = Page.first :uid => "1.0.0" published.visible?.should be_true end end @@ -497,21 +497,21 @@ child_page = Page.new :uid => "newpage" page.things << child_page page.save - S::Content.publish(@final_revision, [page.id, child_page.id]) + ::Content.publish(@final_revision, [page.id, child_page.id]) child_page.hidden?.should be_false page.hide! child_page.reload.hidden?.should be_true - S::Content.publish(@final_revision + 1, [page.id]) + ::Content.publish(@final_revision + 1, [page.id]) - S::Content.with_revision(@final_revision + 1) do + ::Content.with_revision(@final_revision + 1) do published = Page.first :uid => "newpage" published.visible?.should be_false end end @@ -522,48 +522,48 @@ page.hide! child_page.reload.hidden?.should be_true - S::Content.publish(@final_revision, [page.id]) + ::Content.publish(@final_revision, [page.id]) - S::Content.with_revision(@final_revision) do + ::Content.with_revision(@final_revision) do published = Page.first :uid => "1.0.0" published.visible?.should be_false end end - should "maintain correct published visibility for pieces xxx" do + should "maintain correct published visibility for pieces" do page = Page.first :uid => "1" piece = page.things.first piece.hide! - S::Content.publish(@final_revision, [page.id]) - S::Content.with_revision(@final_revision) do + ::Content.publish(@final_revision, [page.id]) + ::Content.with_revision(@final_revision) do piece = Page.first(:uid => "1").things.first piece.visible?.should be_false end - S::Content.publish(@final_revision+1, [page.id]) + ::Content.publish(@final_revision+1, [page.id]) - S::Content.with_revision(@final_revision+1) do + ::Content.with_revision(@final_revision+1) do piece = Page.first(:uid => "1").things.first piece.visible?.should be_false end end - should "maintain correct published visibility for pages xxx" do + should "maintain correct published visibility for pages" do page = Page.first :uid => "1.1.1" page.hide! - S::Content.publish(@final_revision, [page.id]) - S::Content.with_revision(@final_revision) do + ::Content.publish(@final_revision, [page.id]) + ::Content.with_revision(@final_revision) do page = Page.first(:uid => "1.1.1") page.visible?.should be_false end - S::Content.publish(@final_revision+1, [page.id]) + ::Content.publish(@final_revision+1, [page.id]) - S::Content.with_revision(@final_revision+1) do + ::Content.with_revision(@final_revision+1) do page = Page.first(:uid => "1.1.1") page.visible?.should be_false end end @@ -572,15 +572,15 @@ page = Page.first :uid => "1" page.slug = "changed" page.slug = "changed-again" page.hide! - S::Content.publish(@final_revision, [page.id]) - S::Content.with_revision(@final_revision) do + ::Content.publish(@final_revision, [page.id]) + ::Content.with_revision(@final_revision) do %w(1 1.1.1).each do |uid| published_page = Page.first :uid => uid - S::Content.with_editable do + ::Content.with_editable do editable_page = Page.first :uid => uid published_page.hidden?.should == editable_page.hidden? published_page.slug.should == editable_page.slug published_page.path.should == editable_page.path end @@ -590,12 +590,12 @@ should "ignore deletion modifications" do page = Page.first(:uid => "1") page.destroy page = Page.first(:uid => "root") - S::Content.publish(@final_revision, [page.id]) - S::Content.with_revision(@final_revision) do + ::Content.publish(@final_revision, [page.id]) + ::Content.with_revision(@final_revision) do %w(1 1.1.1).each do |uid| published_page = Page.first :uid => uid published_page.should be_nil end published_page = Page.first :uid => "0" @@ -605,10 +605,10 @@ should "clear modifications after publish" do page = Page.first :uid => "1" page.slug = "changed" page.hide! - S::Content.publish(@final_revision, [page.id]) + ::Content.publish(@final_revision, [page.id]) page = Page.first :id => page.id page.pending_modifications.length.should == 0 end end