Commit c3a54560 authored by Peter Leitzen's avatar Peter Leitzen

Use let_it_be and non_existing_record_id in FinderMethods specs

parent cbe50977
......@@ -21,12 +21,13 @@ RSpec.describe FinderMethods do
end
end
let(:user) { create(:user) }
let(:finder) { finder_class.new(user) }
let(:authorized_project) { create(:project) }
let(:unauthorized_project) { create(:project) }
let_it_be(:user) { create(:user) }
let_it_be(:authorized_project) { create(:project) }
let_it_be(:unauthorized_project) { create(:project) }
before do
subject(:finder) { finder_class.new(user) }
before_all do
authorized_project.add_developer(user)
end
......@@ -37,7 +38,7 @@ RSpec.describe FinderMethods do
end
it 'raises not found when the project is not found' do
expect { finder.find_by!(id: 0) }.to raise_error(ActiveRecord::RecordNotFound)
expect { finder.find_by!(id: non_existing_record_id) }.to raise_error(ActiveRecord::RecordNotFound)
end
it 'raises not found the user does not have access' do
......@@ -62,7 +63,7 @@ RSpec.describe FinderMethods do
end
it 'raises not found when the project is not found' do
expect { finder.find(0) }.to raise_error(ActiveRecord::RecordNotFound)
expect { finder.find(non_existing_record_id) }.to raise_error(ActiveRecord::RecordNotFound)
end
it 'raises not found the user does not have access' do
......@@ -76,7 +77,7 @@ RSpec.describe FinderMethods do
end
it 'returns nil when the project is not found' do
expect(finder.find_by(id: 0)).to be_nil
expect(finder.find_by(id: non_existing_record_id)).to be_nil
end
it 'returns nil when the user does not have access' do
......
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