summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2018-01-09 12:09:24 -0800
committerMichael Kozono <mkozono@gmail.com>2018-01-09 12:09:24 -0800
commit3576d59ae95a61dd20e997a619dbc6c8e8a70276 (patch)
treee1fdf5744426907b1753ec93c6f0530bb6b25983
parent48a018c608f3c3474c654ee78f82630e748655f5 (diff)
downloadgitlab-ce-3576d59ae95a61dd20e997a619dbc6c8e8a70276.tar.gz
Revert "Fix Route validation for unchanged path"
This reverts commit 8040edcce8b4e736b4f4857e6709f94aeb5e274c.
-rw-r--r--app/models/route.rb2
-rw-r--r--spec/models/route_spec.rb60
2 files changed, 1 insertions, 61 deletions
diff --git a/app/models/route.rb b/app/models/route.rb
index 412f5fb45a5..7ba3ec06041 100644
--- a/app/models/route.rb
+++ b/app/models/route.rb
@@ -8,7 +8,7 @@ class Route < ActiveRecord::Base
presence: true,
uniqueness: { case_sensitive: false }
- validate :ensure_permanent_paths, if: :path_changed?
+ validate :ensure_permanent_paths
after_create :delete_conflicting_redirects
after_update :delete_conflicting_redirects, if: :path_changed?
diff --git a/spec/models/route_spec.rb b/spec/models/route_spec.rb
index 2f141d96144..ddad6862a63 100644
--- a/spec/models/route_spec.rb
+++ b/spec/models/route_spec.rb
@@ -16,66 +16,6 @@ describe Route do
it { is_expected.to validate_presence_of(:source) }
it { is_expected.to validate_presence_of(:path) }
it { is_expected.to validate_uniqueness_of(:path).case_insensitive }
-
- describe '#ensure_permanent_paths' do
- context 'when the route is not yet persisted' do
- let(:new_route) { Route.new(path: 'foo', source: build(:group)) }
-
- context 'when permanent conflicting redirects exist' do
- it 'is invalid' do
- redirect = RedirectRoute.new(path: 'foo/bar/baz', source: create(:group), permanent: true)
- redirect.save!(validate: false)
-
- expect(new_route.valid?).to be_falsey
- expect(new_route.errors.first[1]).to eq('foo has been taken before. Please use another one')
- end
- end
-
- context 'when no permanent conflicting redirects exist' do
- it 'is valid' do
- expect(new_route.valid?).to be_truthy
- end
- end
- end
-
- context 'when path has changed' do
- before do
- route.path = 'foo'
- end
-
- context 'when permanent conflicting redirects exist' do
- it 'is invalid' do
- redirect = RedirectRoute.new(path: 'foo/bar/baz', source: create(:group), permanent: true)
- redirect.save!(validate: false)
-
- expect(route.valid?).to be_falsey
- expect(route.errors.first[1]).to eq('foo has been taken before. Please use another one')
- end
- end
-
- context 'when no permanent conflicting redirects exist' do
- it 'is valid' do
- expect(route.valid?).to be_truthy
- end
- end
- end
-
- context 'when path has not changed' do
- context 'when permanent conflicting redirects exist' do
- it 'is valid' do
- redirect = RedirectRoute.new(path: 'git_lab/foo/bar', source: create(:group), permanent: true)
- redirect.save!(validate: false)
-
- expect(route.valid?).to be_truthy
- end
- end
- context 'when no permanent conflicting redirects exist' do
- it 'is valid' do
- expect(route.valid?).to be_truthy
- end
- end
- end
- end
end
describe 'callbacks' do