Skip to content

Commit

Permalink
update rspec
Browse files Browse the repository at this point in the history
  • Loading branch information
jimhj committed Oct 29, 2012
1 parent 8cc3679 commit ab97c96
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ gem 'chunky_png', "1.2.5", :require => false
group :development, :test do
# Deploy with Capistrano
gem 'capistrano', :require => false
gem 'rspec-rails'
gem 'rspec-rails', "~> 2.0"
gem 'factory_girl_rails'
gem "capybara", :require => false
end
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ DEPENDENCIES
rails (= 3.2.8)
redis-search (= 0.9.0)
rmmseg-cpp-huacnlee (= 0.2.9)
rspec-rails
rspec-rails (~> 2.0)
sass-rails (~> 3.2.3)
settingslogic (~> 2.0.6)
sidekiq (~> 2.1.0)
Expand Down
2 changes: 1 addition & 1 deletion app/models/tv_drama.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class TvDrama
embeds_many :download_resources

validates :tv_name, :presence => true, :uniqueness => true
# validates_presence_of :cover
validates_presence_of :cover

scope :hots, desc(:likes_count)

Expand Down
2 changes: 1 addition & 1 deletion config/mongoid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test:
default:
hosts:
- 127.0.0.1:27017
database: wakmj_dev
database: wakmj_test

# set these environment variables on your prod server
production:
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/tv_dramas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

factory :tv_drama do
sequence(:tv_name) { |n| "The Test Drama-#{Time.now.to_i.to_s}" }
# cover "http://www.test.com/2.jpg"
remote_cover_url "http://tp2.sinaimg.cn/1856138157/180/5636078673/1.jpg"
verify true
end

Expand Down
29 changes: 19 additions & 10 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,34 @@

end

describe 'like:' do
it "can like tv_drama" do
describe '#like' do
it "can like/unlike tv_drama" do
user.like(tv_drama)
tv_drama.reload
tv_drama.likes_count.should == 3
tv_drama.likes_count.should == 1
tv_drama.liked_user_ids.should include(user.id)

user2.like(tv_drama)
tv_drama.reload
tv_drama.likes_count.should == 2
tv_drama.liked_user_ids.should include(user2.id)
tv_drama.liked_user_ids.should include(user2.id)

user2.unlike(tv_drama)
tv_drama.reload
tv_drama.likes_count.should eq(1)
tv_drama.liked_user_ids.should include(user.id)
tv_drama.liked_user_ids.should_not include(user2.id)

end

# it "can unlike tv_drama" do
# user2.unlike(tv_drama)
# tv_drama.likes_count.should eq(1)
# tv_drama.liked_user_ids.should include(user.id)
# tv_drama.liked_user_ids.should_not include(user2.id)
# end
it "can tell tv_drama wether or not liked by user " do
tv_drama.liked_by_user?(user).should be_true
end
end

describe "#read_notifications" do
it "set user's unread notifications to readed" do
end
end


Expand Down

0 comments on commit ab97c96

Please sign in to comment.