Skip to content

Commit

Permalink
Setting trashed elements not public
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas von Deyen committed Nov 1, 2011
1 parent b48ee02 commit 28d72c0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
3 changes: 2 additions & 1 deletion app/models/element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def store_page(page)
def trash
self.update_attributes({
:page_id => nil,
:folded => true
:folded => true,
:public => false
})
end

Expand Down
33 changes: 26 additions & 7 deletions spec/models/element_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,33 @@
element.ingredient('intro').should == EssenceText.first.ingredient
end

it "should be trashable" do
element = Factory(:element)
element.trash
element.page_id.should == nil
element.folded.should == true
Element.trashed.should include(element)
context "trashed" do

before(:each) do
@element = Factory(:element)
@element.trash
end

it "should be not public" do
@element.public.should be_false
end

it "should have no page" do
@element.page.should == nil
end

it "should be folded" do
@element.folded.should == true
end

end


it "should return a collection of trashed elements" do
@element = Factory(:element)
@element.trash
Element.trashed.should include(@element)
end

it "should raise error if all_for_page method has no page" do
expect { Element.all_for_page(nil) }.should raise_error(TypeError)
end
Expand Down

0 comments on commit 28d72c0

Please sign in to comment.