Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-02-25 21:21:53 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-02-25 21:21:53 +0400
commit345b3d4b72d3e450a65ec92806be019be512da54 (patch)
tree8fe1ef43d699a934a96d72a7069c3dfbb3c9cbb4 /spec/finders/projects_finder_spec.rb
parent645e8d470559b07a22164c55b76195a60fb8b37b (diff)
Update tests and fix Finders readme
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'spec/finders/projects_finder_spec.rb')
-rw-r--r--spec/finders/projects_finder_spec.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/finders/projects_finder_spec.rb b/spec/finders/projects_finder_spec.rb
new file mode 100644
index 00000000000..cc6ee82ab75
--- /dev/null
+++ b/spec/finders/projects_finder_spec.rb
@@ -0,0 +1,51 @@
+require 'spec_helper'
+
+describe ProjectsFinder do
+ let(:user) { create :user }
+ let(:group) { create :group }
+
+ let(:project1) { create(:empty_project, group: group, visibility_level: Project::PUBLIC) }
+ let(:project2) { create(:empty_project, group: group, visibility_level: Project::INTERNAL) }
+ let(:project3) { create(:empty_project, group: group, visibility_level: Project::PRIVATE) }
+ let(:project4) { create(:empty_project, group: group, visibility_level: Project::PRIVATE) }
+
+ context 'non authenticated' do
+ subject { ProjectsFinder.new.execute(nil, group: group) }
+
+ it { should include(project1) }
+ it { should_not include(project2) }
+ it { should_not include(project3) }
+ it { should_not include(project4) }
+ end
+
+ context 'authenticated' do
+ subject { ProjectsFinder.new.execute(user, group: group) }
+
+ it { should include(project1) }
+ it { should include(project2) }
+ it { should_not include(project3) }
+ it { should_not include(project4) }
+ end
+
+ context 'authenticated, project member' do
+ before { project3.team << [user, :developer] }
+
+ subject { ProjectsFinder.new.execute(user, group: group) }
+
+ it { should include(project1) }
+ it { should include(project2) }
+ it { should include(project3) }
+ it { should_not include(project4) }
+ end
+
+ context 'authenticated, group member' do
+ before { group.add_user(user, Gitlab::Access::DEVELOPER) }
+
+ subject { ProjectsFinder.new.execute(user, group: group) }
+
+ it { should include(project1) }
+ it { should include(project2) }
+ it { should include(project3) }
+ it { should include(project4) }
+ end
+end