From e1f904bb9034f0fea70d5494bd3b760e6bd5661d Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Wed, 8 Nov 2023 14:36:55 +0100 Subject: [PATCH] Revert "Add uniqueness validation to repository remote url" --- app/models/repository.rb | 2 +- .../20231107160330_add_unique_to_repository_remote.rb | 5 ----- db/schema.rb | 3 +-- db/seeds.rb | 3 --- test/controllers/repositories_controller_test.rb | 8 +++----- 5 files changed, 5 insertions(+), 16 deletions(-) delete mode 100644 db/migrate/20231107160330_add_unique_to_repository_remote.rb diff --git a/app/models/repository.rb b/app/models/repository.rb index 7ed9d6d880..a9d0922ba0 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -23,7 +23,7 @@ class Repository < ApplicationRecord MEDIA_DIR = 'media'.freeze validates :name, presence: true, uniqueness: { case_sensitive: false } - validates :remote, presence: true, uniqueness: { case_sensitive: false } + validates :remote, presence: true validate :repo_is_accessible, on: :create diff --git a/db/migrate/20231107160330_add_unique_to_repository_remote.rb b/db/migrate/20231107160330_add_unique_to_repository_remote.rb deleted file mode 100644 index 82c57dec43..0000000000 --- a/db/migrate/20231107160330_add_unique_to_repository_remote.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddUniqueToRepositoryRemote < ActiveRecord::Migration[7.1] - def change - add_index :repositories, :remote, unique: true - end -end diff --git a/db/schema.rb b/db/schema.rb index 71cab76545..c7a60a2e37 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2023_11_07_160330) do +ActiveRecord::Schema[7.1].define(version: 2023_10_26_075353) do create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.string "name", null: false t.string "record_type", null: false @@ -396,7 +396,6 @@ t.index ["judge_id"], name: "index_repositories_on_judge_id" t.index ["name"], name: "index_repositories_on_name", unique: true t.index ["path"], name: "index_repositories_on_path", unique: true - t.index ["remote"], name: "index_repositories_on_remote", unique: true end create_table "repository_admins", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| diff --git a/db/seeds.rb b/db/seeds.rb index a1396cd274..070f80080e 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -276,9 +276,6 @@ def fill_series_with_realistic_submissions(s) puts activity_repo.errors.full_messages unless activity_repo.valid? activity_repo.process_activities - # remote must be unique for the repository, and we want to clone it again - activity_repo.update!(remote: '-') - big_activity_repo = Repository.create name: 'A lot of python activities', remote: 'git@github.com:dodona-edu/example-exercises.git', judge: python_judge, allowed_courses: courses Delayed::Worker.delay_jobs = true Dir.glob("#{big_activity_repo.full_path}/*") diff --git a/test/controllers/repositories_controller_test.rb b/test/controllers/repositories_controller_test.rb index 0bc14179a7..8c80b40ba1 100644 --- a/test/controllers/repositories_controller_test.rb +++ b/test/controllers/repositories_controller_test.rb @@ -200,8 +200,6 @@ class RepositoryGitControllerTest < ActionDispatch::IntegrationTest @remote.update_json('echo/config.json', 'make echo private') do |config| config.update 'access' => 'private' end - - @second_remote = local_remote('exercises/lasagna') end def find_echo @@ -224,16 +222,16 @@ def find_echo user = users(:staff) judge = create :judge, :git_stubbed sign_in user - post repositories_path, params: { repository: { name: 'test', remote: @second_remote.path, judge_id: judge.id } } + post repositories_path, params: { repository: { name: 'test', remote: @remote.path, judge_id: judge.id } } end test 'should email during repository creation' do user = users(:staff) judge = create :judge, :git_stubbed sign_in user - @second_remote.update_file('exercises/extra/echo/config.json', 'break config') { '(╯°□°)╯︵ ┻━┻' } + @remote.update_file('echo/config.json', 'break config') { '(╯°□°)╯︵ ┻━┻' } assert_difference 'ActionMailer::Base.deliveries.size', +1 do - post repositories_path, params: { repository: { name: 'test', remote: @second_remote.path, judge_id: judge.id } } + post repositories_path, params: { repository: { name: 'test', remote: @remote.path, judge_id: judge.id } } end end