Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Add uniqueness validation to repository remote url" #5121

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

This file was deleted.

3 changes: 1 addition & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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|
Expand Down
3 changes: 0 additions & 3 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: '[email protected]:dodona-edu/example-exercises.git', judge: python_judge, allowed_courses: courses
Delayed::Worker.delay_jobs = true
Dir.glob("#{big_activity_repo.full_path}/*")
Expand Down
8 changes: 3 additions & 5 deletions test/controllers/repositories_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down