Skip to content

Commit

Permalink
Remove duplicated test from minitest
Browse files Browse the repository at this point in the history
The test was implicitly testing if you can create duplicated issues. So
move *that* test to rspec
  • Loading branch information
coolo authored and eduardoj committed Dec 6, 2019
1 parent bbfa3f8 commit f58aae1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/api/spec/models/attrib_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@

subject { build(:attrib, project: project, attrib_type: attrib_type, issues: [issue]) }

it { expect(subject).to be_invalid }
it { expect(subject.errors.full_messages).to match_array(["Issues can't have issues"]) }
end

Expand Down
11 changes: 11 additions & 0 deletions src/api/spec/models/issue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,16 @@
it 'CVE-XXXX-YYYY should be an invalid name' do
expect { issue_cve.save! }.to raise_error(ActiveRecord::RecordInvalid, /does not match defined regex/)
end

context 'with duplicated issues' do
let(:duplicated_issue) { build(:issue, name: '1234', issue_tracker: issue_tracker) }

it { expect(duplicated_issue).to be_invalid }

it 'has a proper error' do
duplicated_issue.save
expect(duplicated_issue.errors.full_messages).to match_array(['Name has already been taken'])
end
end
end
end
12 changes: 0 additions & 12 deletions src/api/test/unit/attrib_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,6 @@ class AttribTest < ActiveSupport::TestCase
assert_equal 'One', attrib.values.first.value
end

test 'should have no issues' do
attrib_type = AttribType.new(attrib_namespace: @namespace, name: 'AttribIssues')
attrib = Attrib.new(attrib_type: attrib_type, project: Project.first)

bnc = IssueTracker.find_by_name('bnc')
attrib.issues << Issue.new(name: '12345', issue_tracker: bnc)
assert_not attrib.valid?
assert_equal ["can't have issues"], attrib.errors.messages[:issues]
attrib_type.issue_list = true
assert attrib.valid?, "attrib should be valid: #{attrib.errors.messages}"
end

test 'find_by_container_and_fullname' do
project = Project.find_by(name: 'BaseDistro2.0')
attrib = Attrib.find_by_container_and_fullname(project, 'OBS:UpdateProject')
Expand Down

0 comments on commit f58aae1

Please sign in to comment.