Commit 601c24d5 authored by Michael Kozono's avatar Michael Kozono

Add RedirectRoute factory

parent c517788e
FactoryBot.define do
factory :redirect_route do
sequence(:path) { |n| "redirect#{n}" }
source factory: :group
permanent false
trait :permanent do
permanent true
end
trait :temporary do
permanent false
end
end
end
...@@ -23,7 +23,7 @@ describe Route do ...@@ -23,7 +23,7 @@ describe Route do
context 'when permanent conflicting redirects exist' do context 'when permanent conflicting redirects exist' do
it 'is invalid' do it 'is invalid' do
redirect = RedirectRoute.new(path: 'foo/bar/baz', source: create(:group), permanent: true) redirect = build(:redirect_route, :permanent, path: 'foo/bar/baz')
redirect.save!(validate: false) redirect.save!(validate: false)
expect(new_route.valid?).to be_falsey expect(new_route.valid?).to be_falsey
...@@ -45,7 +45,7 @@ describe Route do ...@@ -45,7 +45,7 @@ describe Route do
context 'when permanent conflicting redirects exist' do context 'when permanent conflicting redirects exist' do
it 'is invalid' do it 'is invalid' do
redirect = RedirectRoute.new(path: 'foo/bar/baz', source: create(:group), permanent: true) redirect = build(:redirect_route, :permanent, path: 'foo/bar/baz')
redirect.save!(validate: false) redirect.save!(validate: false)
expect(route.valid?).to be_falsey expect(route.valid?).to be_falsey
...@@ -63,7 +63,7 @@ describe Route do ...@@ -63,7 +63,7 @@ describe Route do
context 'when path has not changed' do context 'when path has not changed' do
context 'when permanent conflicting redirects exist' do context 'when permanent conflicting redirects exist' do
it 'is valid' do it 'is valid' do
redirect = RedirectRoute.new(path: 'git_lab/foo/bar', source: create(:group), permanent: true) redirect = build(:redirect_route, :permanent, path: 'git_lab/foo/bar')
redirect.save!(validate: false) redirect.save!(validate: false)
expect(route.valid?).to be_truthy expect(route.valid?).to be_truthy
......
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