Commit ebdd6eb4
Changed files (4)
app/models/creation.rb
@@ -1,13 +1,12 @@
class Creation < ActiveRecord::Base
validates :name, :presence => true
- #attr_accessible :user_id, :story, :name, :category_ids, :is_restricted, :watermark
belongs_to :user, :counter_cache => true
has_and_belongs_to_many :categories, -> { where unique: true }, :join_table => 'creations_categories', :autosave => true
has_many :photos, -> { order :created_at }, :dependent => :destroy
has_many :favorites, :dependent => :destroy
acts_as_taggable
- #default_scope -> { order("created_at DESC") }
+ default_scope -> { order("created_at DESC") }
# to be removed and moved to the DisplayCreationDTO
def to_param
spec/features/creations_spec.rb
@@ -10,6 +10,7 @@ describe "Creations" do
creation.save!
visit creations_path
end
+
it "works! (now write some real specs)" do
page.should have_content("CakeSide")
end
spec/models/creation_spec.rb
@@ -10,4 +10,18 @@ describe Creation do
Creation.find(sut.id).name.should == "HELLO WORLD"
end
end
+
+ describe "when loading a bunch of creations" do
+ let!(:oldest) { create(:creation) }
+ let!(:newest) { create(:creation) }
+ let(:results) { Creation.all }
+
+ it "should load the newest first" do
+ results.first.should == newest
+ end
+
+ it "should load the oldest last" do
+ results.last.should == oldest
+ end
+ end
end
.rspec
@@ -1,2 +1,1 @@
---colour
---format documentation
+--colour
\ No newline at end of file