diff options
author | Ciro Santilli <ciro.santilli@gmail.com> | 2014-06-26 11:49:14 +0400 |
---|---|---|
committer | Ciro Santilli <ciro.santilli@gmail.com> | 2014-07-18 00:47:16 +0400 |
commit | 714f7201d3362793d11f33793e5ef6dc83bdd2f0 (patch) | |
tree | 54e6a4cc5ef89e132a123231b439b83de0e54d54 /spec/controllers/projects_controller_spec.rb | |
parent | b634d2801e6abdd039447f53ec5d9cf709f66b06 (diff) |
Add project stars.
Diffstat (limited to 'spec/controllers/projects_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects_controller_spec.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 944df5314bd..c7a48898c56 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -2,6 +2,7 @@ require('spec_helper') describe ProjectsController do let(:project) { create(:project) } + let(:public_project) { create(:project, :public) } let(:user) { create(:user) } let(:jpg) { fixture_file_upload(Rails.root + 'spec/fixtures/rails_sample.jpg', 'image/jpg') } let(:txt) { fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain') } @@ -40,4 +41,17 @@ describe ProjectsController do end end end + + describe "POST #toggle_star" do + it "increases star count if user is signed in" do + sign_in(user) + post :toggle_star, id: public_project.to_param + expect(public_project.star_count).to eq(1) + end + + it "does nothing if user is not signed in" do + post :toggle_star, id: public_project.to_param + expect(public_project.star_count).to eq(0) + end + end end |