Skip to content

Commit

Permalink
Change api key error message for when rubygem cannot be found from it…
Browse files Browse the repository at this point in the history
…s name
  • Loading branch information
jenshenny committed Apr 24, 2023
1 parent 1d6ce40 commit e997bb9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/api_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def rubygem_id=(id)
def rubygem_name=(name)
self.rubygem_id = name.blank? ? nil : Rubygem.find_by_name!(name).id
rescue ActiveRecord::RecordNotFound
errors.add :rubygem, "that is selected cannot be scoped to this key"
errors.add :rubygem, "could not be found"
end

def soft_delete!(ownership: nil)
Expand Down
2 changes: 1 addition & 1 deletion test/functional/api/v1/api_keys_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def self.should_expect_otp_for_update
should respond_with :unprocessable_entity

should "respond with an error" do
assert_equal "Rubygem that is selected cannot be scoped to this key", response.body
assert_equal "Rubygem could not be found", response.body
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/models/api_key_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class ApiKeyTest < ActiveSupport::TestCase

should "add error when name is not a valid gem name" do
api_key = ApiKey.new(hashed_key: SecureRandom.hex(24), push_rubygem: true, user: @ownership.user, rubygem_name: "invalid-gem-name")
assert_contains api_key.errors[:rubygem], "that is selected cannot be scoped to this key"
assert_contains api_key.errors[:rubygem], "could not be found"
end
end
end
Expand Down

0 comments on commit e997bb9

Please sign in to comment.