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/models | |
parent | b634d2801e6abdd039447f53ec5d9cf709f66b06 (diff) |
Add project stars.
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/project_spec.rb | 18 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 13 |
2 files changed, 31 insertions, 0 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index c3263ed0fe7..c2ebfbd9229 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -240,4 +240,22 @@ describe Project do it { project.open_branches.map(&:name).should include('bootstrap') } it { project.open_branches.map(&:name).should_not include('master') } end + + describe "#count_star" do + it "counts stars" do + user1 = create :user + user2 = create :user + project = create :project, :public + + expect(project.star_count).to eq(0) + user1.toggle_star(project) + expect(project.star_count).to eq(1) + user2.toggle_star(project) + expect(project.star_count).to eq(2) + user1.toggle_star(project) + expect(project.star_count).to eq(1) + user2.toggle_star(project) + expect(project.star_count).to eq(0) + end + end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index a36b57a95de..b6ffb6ac24b 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -355,4 +355,17 @@ describe User do expect(user.short_website_url).to eq 'test.com' end end + + describe "#toggle_star" do + it "toggles stars" do + user = create :user + project = create :project, :public + + expect(user.starred?(project)).to be_false + user.toggle_star(project) + expect(user.starred?(project)).to be_true + user.toggle_star(project) + expect(user.starred?(project)).to be_false + end + end end |