BigW Consortium Gitlab

Commit dc3d40ff by Mike Greiling

prefer unit test on model over view test

parent 1c5a5065
......@@ -243,4 +243,26 @@ describe CommitStatus, models: true do
.to be_a Gitlab::Ci::Status::Success
end
end
describe '#sortable_name' do
subject { commit_status.sortable_name }
tests = {
'karma' => ['karma'],
'karma 0 20' => ['karma ', 0, ' ', 20],
'karma 10 20' => ['karma ', 10, ' ', 20],
'karma 50:100' => ['karma ', 50, ':', 100],
'karma 1.10' => ['karma ', 1, '.', 10],
'karma 1.5.1' => ['karma ', 1, '.', 5, '.', 1],
'karma 1 a' => ['karma ', 1, ' a']
}
tests.each do |name, sortable_name|
it "'#{name}' sorts as '#{sortable_name}'" do
commit_status.name = name
is_expected.to eq(sortable_name)
end
end
end
end
......@@ -45,41 +45,6 @@ describe 'projects/pipelines/show' do
expect(rendered).to have_text('jenkins')
end
it 'lists builds in the correct sort order' do
create_build('test', 1, 'karma 0 20', :created)
create_build('test', 1, 'karma 12 20', :created)
create_build('test', 1, 'karma 1 20', :created)
create_build('test', 1, 'karma 10 20', :created)
create_build('test', 1, 'karma 11 20', :created)
create_build('test', 1, 'karma 2 20', :created)
create_build('test', 1, 'test 1.10', :created)
create_build('test', 1, 'test 1.5.1', :created)
create_build('test', 1, 'test 1 a', :created)
render
# spaced builds order
expected_order_1 = [
'karma 0 20',
'karma 1 20',
'karma 2 20',
'karma 10 20',
'karma 11 20',
'karma 12 20'
].join(' ')
expect(rendered).to have_text(expected_order_1)
# decimal builds order
expected_order_2 = [
'test 1 a',
'test 1.5.1',
'test 1.10'
].join(' ')
expect(rendered).to have_text(expected_order_2)
end
private
def create_build(stage, stage_idx, name, status)
......
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