diff options
author | James Lopez <james@jameslopez.es> | 2016-04-21 13:20:00 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-04-21 13:20:00 +0200 |
commit | b09b175def7c66487d4571d90f23f613d868f25c (patch) | |
tree | 82394907230be62f696d2b00f5163564cc476f47 | |
parent | 2d2b73ae4954a96d060fdf21ce8e95ccbdebe68f (diff) | |
download | gitlab-ce-b09b175def7c66487d4571d90f23f613d868f25c.tar.gz |
refactored specs based on feedbackfix/label-filters
-rw-r--r-- | spec/features/issues/filter_by_labels_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/concerns/issuable_spec.rb | 45 |
2 files changed, 18 insertions, 31 deletions
diff --git a/spec/features/issues/filter_by_labels_spec.rb b/spec/features/issues/filter_by_labels_spec.rb index 29c3f9eaad4..7f654684143 100644 --- a/spec/features/issues/filter_by_labels_spec.rb +++ b/spec/features/issues/filter_by_labels_spec.rb @@ -6,12 +6,8 @@ feature 'Issue filtering by Labels', feature: true do let(:project) { create(:project, :public) } let!(:user) { create(:user)} let!(:label) { create(:label, project: project) } - let(:bug) { create(:label, project: project, title: 'bug') } - let(:feature) { create(:label, project: project, title: 'feature') } - let(:enhancement) { create(:label, project: project, title: 'enhancement') } before do - bug = create(:label, project: project, title: 'bug') feature = create(:label, project: project, title: 'feature') enhancement = create(:label, project: project, title: 'enhancement') diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb index cf9c1cc1fba..4a4cd093435 100644 --- a/spec/models/concerns/issuable_spec.rb +++ b/spec/models/concerns/issuable_spec.rb @@ -214,41 +214,32 @@ describe Issue, "Issuable" do end describe ".with_label" do - let(:example_label) { 'test1' } - let(:example_labels) { ['test1', 'test2'] } + let(:project) { create(:project, :public) } + let(:bug) { create(:label, project: project, title: 'bug') } + let(:feature) { create(:label, project: project, title: 'feature') } + let(:enhancement) { create(:label, project: project, title: 'enhancement') } + let(:issue1) { create(:issue, title: "Bugfix1", project: project) } + let(:issue2) { create(:issue, title: "Bugfix2", project: project) } + let(:issue3) { create(:issue, title: "Feature1", project: project) } before(:each) do - setup_other_issue + issue1.labels << bug + issue1.labels << feature + issue2.labels << bug + issue2.labels << enhancement + issue3.labels << feature end - it 'finds the correct issue with 1 label' do - setup_labels([example_label]) - - expect(Issue.with_label(example_label)).to eq([issue]) - end - - it 'finds the correct issue with 2 labels' do - setup_labels(example_labels) - - expect(Issue.with_label(example_labels)).to eq([issue]) + it 'finds the correct issue containing just enhancement label' do + expect(Issue.with_label(enhancement.title)).to match_array([issue2]) end - it 'finds the correct issue with 1 of 2 labels' do - setup_labels(example_labels) - - expect(Issue.with_label(example_label)).to eq([issue]) - end - - def setup_labels(label_names) - labels = label_names.map do |label| - create(:label, project: issue.project, title: label) - end - issue.labels << labels + it 'finds the correct issues containing the same label' do + expect(Issue.with_label(bug.title)).to match_array([issue1, issue2]) end - def setup_other_issue - issue2 = create(:issue) - issue2.labels << create(:label, project: issue2.project, title: 'other_label') + it 'finds the correct issues containing only both labels' do + expect(Issue.with_label([bug.title, enhancement.title])).to match_array([issue2]) end end end |