diff --git a/app/models/api_key.rb b/app/models/api_key.rb index 297a877c14a..34fb74efe5f 100644 --- a/app/models/api_key.rb +++ b/app/models/api_key.rb @@ -39,7 +39,7 @@ def mfa_enabled? def rubygem_id=(id) self.ownership = id.blank? ? nil : user.ownerships.find_by!(rubygem_id: id) rescue ActiveRecord::RecordNotFound - errors.add :rubygem, "that is selected cannot be scoped to this key" + errors.add :rubygem, "must be a gem that you are an owner of" end def rubygem_name=(name) diff --git a/test/functional/api_keys_controller_test.rb b/test/functional/api_keys_controller_test.rb index 8abfb343459..cb47b303b9b 100644 --- a/test/functional/api_keys_controller_test.rb +++ b/test/functional/api_keys_controller_test.rb @@ -147,7 +147,7 @@ class ApiKeysControllerTest < ActionController::TestCase should "display error with invalid id" do post :create, params: { api_key: { name: "gem scope", add_owner: true, rubygem_id: -1 } } - assert_equal "Rubygem that is selected cannot be scoped to this key", flash[:error] + assert_equal "Rubygem must be a gem that you are an owner of", flash[:error] assert_empty @user.reload.api_keys end @@ -235,7 +235,7 @@ class ApiKeysControllerTest < ActionController::TestCase assert_no_changes @api_key do patch :update, params: { api_key: { rubygem_id: -1 }, id: @api_key.id } - assert_equal "Rubygem that is selected cannot be scoped to this key", flash[:error] + assert_equal "Rubygem must be a gem that you are an owner of", flash[:error] end end diff --git a/test/models/api_key_test.rb b/test/models/api_key_test.rb index b668d787c5d..1cf65bf1cb3 100644 --- a/test/models/api_key_test.rb +++ b/test/models/api_key_test.rb @@ -102,8 +102,7 @@ class ApiKeyTest < ActiveSupport::TestCase should "add error when id is not associated with the user" do api_key = ApiKey.new(hashed_key: SecureRandom.hex(24), push_rubygem: true, user: @ownership.user, rubygem_id: -1) - - assert_contains api_key.errors[:rubygem], "that is selected cannot be scoped to this key" + assert_contains api_key.errors[:rubygem], "must be a gem that you are an owner of" end end @@ -121,7 +120,7 @@ class ApiKeyTest < ActiveSupport::TestCase should "add error when gem is not associated with the user" do rubygem = create(:rubygem, name: "another-gem") api_key = ApiKey.new(hashed_key: SecureRandom.hex(24), push_rubygem: true, user: @ownership.user, rubygem_name: rubygem.name) - assert_contains api_key.errors[:rubygem], "that is selected cannot be scoped to this key" + assert_contains api_key.errors[:rubygem], "must be a gem that you are an owner of" end should "add error when name is not a valid gem name" do diff --git a/test/system/api_keys_test.rb b/test/system/api_keys_test.rb index 474e4d775c1..8ae67f502a2 100644 --- a/test/system/api_keys_test.rb +++ b/test/system/api_keys_test.rb @@ -100,7 +100,7 @@ class ApiKeysTest < ApplicationSystemTestCase click_button "Create" assert page.has_css? ".flash" - assert page.has_content? "Rubygem that is selected cannot be scoped to this key" + assert page.has_content? "Rubygem must be a gem that you are an owner of" assert_empty @user.api_keys end @@ -211,7 +211,7 @@ class ApiKeysTest < ApplicationSystemTestCase click_button "Update" assert page.has_css? ".flash" - assert page.has_content? "Rubygem that is selected cannot be scoped to this key" + assert page.has_content? "Rubygem must be a gem that you are an owner of" assert_equal @ownership.rubygem, api_key.reload.rubygem end