BigW Consortium Gitlab

Commit b09b175d by James Lopez

refactored specs based on feedback

parent 2d2b73ae
......@@ -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')
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment