diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-07-30 16:05:43 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-07-30 16:05:43 +0300 |
commit | 70f868b737af99c8a8697a3cb5e19b8da3d9c3d9 (patch) | |
tree | 1124b60e0e2a3583a7be04f0311758654a7ca0db | |
parent | 593df8e69a81a3ab0a4755db74dc282c00e02ef5 (diff) | |
download | gitlab-ce-70f868b737af99c8a8697a3cb5e19b8da3d9c3d9.tar.gz |
Fix tests
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r-- | features/project/issues/labels.feature | 2 | ||||
-rw-r--r-- | features/steps/project/filter_labels.rb | 7 | ||||
-rw-r--r-- | features/steps/project/labels.rb | 10 | ||||
-rw-r--r-- | features/steps/shared/project.rb | 11 | ||||
-rw-r--r-- | lib/api/projects.rb | 2 | ||||
-rw-r--r-- | spec/requests/api/labels_spec.rb | 24 | ||||
-rw-r--r-- | spec/requests/api/projects_spec.rb | 49 |
7 files changed, 35 insertions, 70 deletions
diff --git a/features/project/issues/labels.feature b/features/project/issues/labels.feature index e601a41bfc4..3c6a63ced2b 100644 --- a/features/project/issues/labels.feature +++ b/features/project/issues/labels.feature @@ -2,7 +2,7 @@ Feature: Project Labels Background: Given I sign in as a user And I own project "Shop" - And project "Shop" have issues tags: "bug", "feature" + And project "Shop" has labels: "bug", "feature", "enhancement" Given I visit project "Shop" labels page Scenario: I should see active milestones diff --git a/features/steps/project/filter_labels.rb b/features/steps/project/filter_labels.rb index 48e1108c21a..9b31a6d9da2 100644 --- a/features/steps/project/filter_labels.rb +++ b/features/steps/project/filter_labels.rb @@ -3,13 +3,6 @@ class ProjectFilterLabels < Spinach::FeatureSteps include SharedProject include SharedPaths - step 'project "Shop" has labels: "bug", "feature", "enhancement"' do - project = Project.find_by(name: "Shop") - create(:label, project: project, title: 'bug') - create(:label, project: project, title: 'feature') - create(:label, project: project, title: 'enhancement') - end - step 'I should see "bug" in labels filter' do within ".labels-filter" do page.should have_content "bug" diff --git a/features/steps/project/labels.rb b/features/steps/project/labels.rb index 73d00b0004e..6e792e94342 100644 --- a/features/steps/project/labels.rb +++ b/features/steps/project/labels.rb @@ -4,20 +4,14 @@ class ProjectLabels < Spinach::FeatureSteps include SharedPaths Then 'I should see label "bug"' do - within ".labels-table" do + within ".manage-labels-list" do page.should have_content "bug" end end And 'I should see label "feature"' do - within ".labels-table" do + within ".manage-labels-list" do page.should have_content "feature" end end - - And 'project "Shop" have issues tags: "bug", "feature"' do - project = Project.find_by(name: "Shop") - label1 = create(:label, project: project, title: 'bug') - label2 = create(:label, project: project, title: 'feature') - end end diff --git a/features/steps/shared/project.rb b/features/steps/shared/project.rb index 1d894b33fbd..e31d349a45f 100644 --- a/features/steps/shared/project.rb +++ b/features/steps/shared/project.rb @@ -123,10 +123,6 @@ module SharedProject project.team << [user, :master] end - # ---------------------------------------- - # Empty projects - # ---------------------------------------- - step 'public empty project "Empty Public Project"' do create :empty_project, :public, name: "Empty Public Project" end @@ -135,4 +131,11 @@ module SharedProject project = Project.find_by(name: "Community") 2.times { create(:note_on_issue, project: project) } end + + step 'project "Shop" has labels: "bug", "feature", "enhancement"' do + project = Project.find_by(name: "Shop") + create(:label, project: project, title: 'bug') + create(:label, project: project, title: 'feature') + create(:label, project: project, title: 'enhancement') + end end diff --git a/lib/api/projects.rb b/lib/api/projects.rb index ab272426ce0..88c73bff32d 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -222,7 +222,7 @@ module API # Example Request: # GET /projects/:id/labels get ':id/labels' do - @labels = user_project.issues_labels + @labels = user_project.labels present @labels, with: Entities::Label end end diff --git a/spec/requests/api/labels_spec.rb b/spec/requests/api/labels_spec.rb new file mode 100644 index 00000000000..d40c2c21cec --- /dev/null +++ b/spec/requests/api/labels_spec.rb @@ -0,0 +1,24 @@ +require 'spec_helper' + +describe API::API, api: true do + include ApiHelpers + + let(:user) { create(:user) } + let(:project) { create(:project, creator_id: user.id, namespace: user.namespace) } + let!(:label1) { create(:label, title: 'label1', project: project) } + + before do + project.team << [user, :master] + end + + + describe 'GET /projects/:id/labels' do + it 'should return project labels' do + get api("/projects/#{project.id}/labels", user) + response.status.should == 200 + json_response.should be_an Array + json_response.size.should == 1 + json_response.first['name'].should == label1.name + end + end +end diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 41841e855fd..12a3a07ff76 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -10,13 +10,6 @@ describe API::API, api: true do let(:snippet) { create(:project_snippet, author: user, project: project, title: 'example') } let(:users_project) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) } let(:users_project2) { create(:users_project, user: user3, project: project, project_access: UsersProject::DEVELOPER) } - let(:issue_with_labels) { create(:issue, author: user, assignee: user, project: project, :label_list => "label1, label2") } - let(:merge_request_with_labels) do - create(:merge_request, :simple, author: user, assignee: user, - source_project: project, target_project: project, title: 'Test', - label_list: 'label3, label4') - end - describe "GET /projects" do before { project } @@ -634,46 +627,4 @@ describe API::API, api: true do end end end - - describe 'GET /projects/:id/labels' do - context 'with an issue' do - before { issue_with_labels } - - it 'should return project labels' do - get api("/projects/#{project.id}/labels", user) - response.status.should == 200 - json_response.should be_an Array - json_response.first['name'].should == issue_with_labels.labels.first.name - json_response.last['name'].should == issue_with_labels.labels.last.name - end - end - - context 'with a merge request' do - before { merge_request_with_labels } - - it 'should return project labels' do - get api("/projects/#{project.id}/labels", user) - response.status.should == 200 - json_response.should be_an Array - json_response.first['name'].should == merge_request_with_labels.labels.first.name - json_response.last['name'].should == merge_request_with_labels.labels.last.name - end - end - - context 'with an issue and a merge request' do - before do - issue_with_labels - merge_request_with_labels - end - - it 'should return project labels from both' do - get api("/projects/#{project.id}/labels", user) - response.status.should == 200 - json_response.should be_an Array - all_labels = issue_with_labels.labels.map(&:name).to_a - .concat(merge_request_with_labels.labels.map(&:name).to_a) - json_response.map { |e| e['name'] }.should =~ all_labels - end - end - end end |