diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-02-25 19:21:53 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-02-25 19:21:53 +0200 |
commit | 345b3d4b72d3e450a65ec92806be019be512da54 (patch) | |
tree | 8fe1ef43d699a934a96d72a7069c3dfbb3c9cbb4 /spec | |
parent | 645e8d470559b07a22164c55b76195a60fb8b37b (diff) | |
download | gitlab-ce-345b3d4b72d3e450a65ec92806be019be512da54.tar.gz |
Update tests and fix Finders readme
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/finders/issues_finder_spec.rb (renamed from spec/services/filtering_service_spec.rb) | 37 | ||||
-rw-r--r-- | spec/finders/merge_requests_finder_spec.rb | 37 | ||||
-rw-r--r-- | spec/finders/projects_finder_spec.rb (renamed from spec/services/projects_collect_service_spec.rb) | 10 |
3 files changed, 49 insertions, 35 deletions
diff --git a/spec/services/filtering_service_spec.rb b/spec/finders/issues_finder_spec.rb index 92971d0be12..7489e56f423 100644 --- a/spec/services/filtering_service_spec.rb +++ b/spec/finders/issues_finder_spec.rb @@ -1,13 +1,10 @@ require 'spec_helper' -describe FilteringService do +describe IssuesFinder do let(:user) { create :user } let(:user2) { create :user } let(:project1) { create(:project) } let(:project2) { create(:project) } - let(:merge_request1) { create(:merge_request, author: user, source_project: project1, target_project: project2) } - let(:merge_request2) { create(:merge_request, author: user, source_project: project2, target_project: project1) } - let(:merge_request3) { create(:merge_request, author: user, source_project: project2, target_project: project2) } let(:issue1) { create(:issue, assignee: user, project: project1) } let(:issue2) { create(:issue, assignee: user, project: project2) } let(:issue3) { create(:issue, assignee: user2, project: project2) } @@ -18,27 +15,7 @@ describe FilteringService do project2.team << [user2, :developer] end - describe 'merge requests' do - before :each do - merge_request1 - merge_request2 - merge_request3 - end - - it 'should filter by scope' do - params = { scope: 'authored', state: 'opened' } - merge_requests = FilteringService.new.execute(MergeRequest, user, params) - merge_requests.size.should == 3 - end - - it 'should filter by project' do - params = { project_id: project1.id, scope: 'authored', state: 'opened' } - merge_requests = FilteringService.new.execute(MergeRequest, user, params) - merge_requests.size.should == 1 - end - end - - describe 'issues' do + describe :execute do before :each do issue1 issue2 @@ -47,31 +24,31 @@ describe FilteringService do it 'should filter by all' do params = { scope: "all", state: 'opened' } - issues = FilteringService.new.execute(Issue, user, params) + issues = IssuesFinder.new.execute(user, params) issues.size.should == 3 end it 'should filter by assignee' do params = { scope: "assigned-to-me", state: 'opened' } - issues = FilteringService.new.execute(Issue, user, params) + issues = IssuesFinder.new.execute(user, params) issues.size.should == 2 end it 'should filter by project' do params = { scope: "assigned-to-me", state: 'opened', project_id: project1.id } - issues = FilteringService.new.execute(Issue, user, params) + issues = IssuesFinder.new.execute(user, params) issues.size.should == 1 end it 'should be empty for unauthorized user' do params = { scope: "all", state: 'opened' } - issues = FilteringService.new.execute(Issue, nil, params) + issues = IssuesFinder.new.execute(nil, params) issues.size.should be_zero end it 'should not include unauthorized issues' do params = { scope: "all", state: 'opened' } - issues = FilteringService.new.execute(Issue, user2, params) + issues = IssuesFinder.new.execute(user2, params) issues.size.should == 2 issues.should_not include(issue1) issues.should include(issue2) diff --git a/spec/finders/merge_requests_finder_spec.rb b/spec/finders/merge_requests_finder_spec.rb new file mode 100644 index 00000000000..76f9e753dd2 --- /dev/null +++ b/spec/finders/merge_requests_finder_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +describe MergeRequestsFinder do + let(:user) { create :user } + let(:user2) { create :user } + let(:project1) { create(:project) } + let(:project2) { create(:project) } + let(:merge_request1) { create(:merge_request, author: user, source_project: project1, target_project: project2) } + let(:merge_request2) { create(:merge_request, author: user, source_project: project2, target_project: project1) } + let(:merge_request3) { create(:merge_request, author: user, source_project: project2, target_project: project2) } + + before do + project1.team << [user, :master] + project2.team << [user, :developer] + project2.team << [user2, :developer] + end + + describe :execute do + before :each do + merge_request1 + merge_request2 + merge_request3 + end + + it 'should filter by scope' do + params = { scope: 'authored', state: 'opened' } + merge_requests = MergeRequestsFinder.new.execute(user, params) + merge_requests.size.should == 3 + end + + it 'should filter by project' do + params = { project_id: project1.id, scope: 'authored', state: 'opened' } + merge_requests = MergeRequestsFinder.new.execute(user, params) + merge_requests.size.should == 1 + end + end +end diff --git a/spec/services/projects_collect_service_spec.rb b/spec/finders/projects_finder_spec.rb index 107c6dce7c0..cc6ee82ab75 100644 --- a/spec/services/projects_collect_service_spec.rb +++ b/spec/finders/projects_finder_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Projects::CollectService do +describe ProjectsFinder do let(:user) { create :user } let(:group) { create :group } @@ -10,7 +10,7 @@ describe Projects::CollectService do let(:project4) { create(:empty_project, group: group, visibility_level: Project::PRIVATE) } context 'non authenticated' do - subject { Projects::CollectService.new.execute(nil, group: group) } + subject { ProjectsFinder.new.execute(nil, group: group) } it { should include(project1) } it { should_not include(project2) } @@ -19,7 +19,7 @@ describe Projects::CollectService do end context 'authenticated' do - subject { Projects::CollectService.new.execute(user, group: group) } + subject { ProjectsFinder.new.execute(user, group: group) } it { should include(project1) } it { should include(project2) } @@ -30,7 +30,7 @@ describe Projects::CollectService do context 'authenticated, project member' do before { project3.team << [user, :developer] } - subject { Projects::CollectService.new.execute(user, group: group) } + subject { ProjectsFinder.new.execute(user, group: group) } it { should include(project1) } it { should include(project2) } @@ -41,7 +41,7 @@ describe Projects::CollectService do context 'authenticated, group member' do before { group.add_user(user, Gitlab::Access::DEVELOPER) } - subject { Projects::CollectService.new.execute(user, group: group) } + subject { ProjectsFinder.new.execute(user, group: group) } it { should include(project1) } it { should include(project2) } |