Skip to content

Commit

Permalink
Revert "Add uniqueness validation to repository remote url"
Browse files Browse the repository at this point in the history
  • Loading branch information
jorg-vr authored Nov 8, 2023
1 parent df937f2 commit e1f904b
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 16 deletions.
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
5 changes: 0 additions & 5 deletions db/migrate/20231107160330_add_unique_to_repository_remote.rb

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

0 comments on commit e1f904b

Please sign in to comment.