Commit 0e5ba3c4
Changed files (5)
app
models
spec
controllers
models
app/models/creation.rb
@@ -36,11 +36,6 @@ class Creation < ActiveRecord::Base
photo.save!
end
- def publish
- self.update_attribute(:is_published, true)
- self.save!
- end
-
def published?
photos.count > 0
end
db/migrate/20121108032630_remove_is_published_from_creations.rb
@@ -0,0 +1,9 @@
+class RemoveIsPublishedFromCreations < ActiveRecord::Migration
+ def up
+ remove_column :creations, :is_published
+ end
+
+ def down
+ add_column :creations, :is_published, :boolean
+ end
+end
db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20121108031631) do
+ActiveRecord::Schema.define(:version => 20121108032630) do
create_table "active_admin_comments", :force => true do |t|
t.integer "resource_id", :null => false
@@ -86,7 +86,6 @@ ActiveRecord::Schema.define(:version => 20121108031631) do
t.string "image"
t.boolean "is_restricted", :default => false, :null => false
t.string "watermark"
- t.boolean "is_published", :default => false
end
create_table "creations_categories", :id => false, :force => true do |t|
spec/controllers/creations_controller_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
describe CreationsController do
let(:user){ FactoryGirl.create(:user) }
- let(:creation){ FactoryGirl.create(:creation, :user => user, :is_published => true) }
+ let(:creation){ FactoryGirl.create(:creation, :user => user) }
before(:each) do
http_login(user)
spec/models/creation_spec.rb
@@ -3,25 +3,11 @@ require 'spec_helper'
describe Creation do
let(:sut) { FactoryGirl.create(:creation) }
- context "when not published" do
- it "should return false" do
- sut.is_published.should == false
- end
- end
- context "when published" do
- it "should return true" do
- Creation.find(sut.id).is_published.should == true
- end
- before(:each) do
- sut.publish
- end
- end
-
describe "should be able to set attributes" do
- it "should save is_published" do
- sut.is_published=true
+ it "should save name" do
+ sut.name="HELLO WORLD"
sut.save
- Creation.find(sut.id).is_published.should == true
+ Creation.find(sut.id).name.should == "HELLO WORLD"
end
end
end