1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-19 05:09:38 +02:00

Fix linting issues and update API key test for source validation

- Remove trailing whitespace in auth controller and mobile device model
- Update API key test to expect new validation message with source

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Josh Pigford 2025-06-18 08:28:32 -05:00
parent 9336719242
commit 8296e10246
4 changed files with 7 additions and 5 deletions

View file

@ -175,7 +175,7 @@ module Api
def create_or_update_device(user) def create_or_update_device(user)
# Handle both string and symbol keys # Handle both string and symbol keys
device_data = params[:device].permit(:device_id, :device_name, :device_type, :os_version, :app_version) device_data = params[:device].permit(:device_id, :device_name, :device_type, :os_version, :app_version)
device = user.mobile_devices.find_or_initialize_by(device_id: device_data[:device_id]) device = user.mobile_devices.find_or_initialize_by(device_id: device_data[:device_id])
device.update!(device_data.merge(last_seen_at: Time.current)) device.update!(device_data.merge(last_seen_at: Time.current))
device device

View file

@ -27,7 +27,7 @@ class MobileDevice < ApplicationRecord
scopes: "read_write", # Use the configured scope scopes: "read_write", # Use the configured scope
confidential: false # Public client for mobile confidential: false # Public client for mobile
) )
# Store the association # Store the association
update!(oauth_application: app) update!(oauth_application: app)
app app
@ -35,7 +35,7 @@ class MobileDevice < ApplicationRecord
def active_tokens def active_tokens
return Doorkeeper::AccessToken.none unless oauth_application return Doorkeeper::AccessToken.none unless oauth_application
Doorkeeper::AccessToken Doorkeeper::AccessToken
.where(application: oauth_application) .where(application: oauth_application)
.where(resource_owner_id: user_id) .where(resource_owner_id: user_id)

4
db/schema.rb generated
View file

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.2].define(version: 2025_06_18_110736) do ActiveRecord::Schema[7.2].define(version: 2025_06_18_120703) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto" enable_extension "pgcrypto"
enable_extension "plpgsql" enable_extension "plpgsql"
@ -441,7 +441,9 @@ ActiveRecord::Schema[7.2].define(version: 2025_06_18_110736) do
t.datetime "last_seen_at" t.datetime "last_seen_at"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.integer "oauth_application_id"
t.index ["device_id"], name: "index_mobile_devices_on_device_id", unique: true t.index ["device_id"], name: "index_mobile_devices_on_device_id", unique: true
t.index ["oauth_application_id"], name: "index_mobile_devices_on_oauth_application_id"
t.index ["user_id", "device_id"], name: "index_mobile_devices_on_user_id_and_device_id", unique: true t.index ["user_id", "device_id"], name: "index_mobile_devices_on_user_id_and_device_id", unique: true
t.index ["user_id"], name: "index_mobile_devices_on_user_id" t.index ["user_id"], name: "index_mobile_devices_on_user_id"
end end

View file

@ -146,7 +146,7 @@ class ApiKeyTest < ActiveSupport::TestCase
) )
assert_not second_key.valid? assert_not second_key.valid?
assert_includes second_key.errors[:user], "can only have one active API key" assert_includes second_key.errors[:user], "can only have one active API key per source (web)"
end end
test "should allow user to have new active key after revoking old one" do test "should allow user to have new active key after revoking old one" do