The personal finance app for everyone
Fix linting issues and update API key test for source validation
Josh Pigford8296e102464b
diff --git a/app/controllers/api/v1/auth_controller.rb b/app/controllers/api/v1/auth_controller.rbindex 9e5e2768..4f20b934 100644--- a/app/controllers/api/v1/auth_controller.rb+++ b/app/controllers/api/v1/auth_controller.rb@@ -175,7 +175,7 @@ module Apidef create_or_update_device(user)# Handle both string and symbol keysdevice_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.update!(device_data.merge(last_seen_at: Time.current))devicediff --git a/app/models/mobile_device.rb b/app/models/mobile_device.rbindex 106b2928..e334e3a8 100644--- a/app/models/mobile_device.rb+++ b/app/models/mobile_device.rb@@ -27,7 +27,7 @@ class MobileDevice < ApplicationRecordscopes: "read_write", # Use the configured scopeconfidential: false # Public client for mobile)-+# Store the associationupdate!(oauth_application: app)app@@ -35,7 +35,7 @@ class MobileDevice < ApplicationRecorddef active_tokensreturn Doorkeeper::AccessToken.none unless oauth_application-+Doorkeeper::AccessToken.where(application: oauth_application).where(resource_owner_id: user_id)diff --git a/db/schema.rb b/db/schema.rbindex e817a168..b73e3a8d 100644--- a/db/schema.rb+++ b/db/schema.rb@@ -10,7 +10,7 @@## 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 databaseenable_extension "pgcrypto"enable_extension "plpgsql"@@ -441,7 +441,9 @@ ActiveRecord::Schema[7.2].define(version: 2025_06_18_110736) dot.datetime "last_seen_at"t.datetime "created_at", null: falset.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 ["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: truet.index ["user_id"], name: "index_mobile_devices_on_user_id"enddiff --git a/test/models/api_key_test.rb b/test/models/api_key_test.rbindex d42c2955..d437e2c8 100644--- a/test/models/api_key_test.rb+++ b/test/models/api_key_test.rb@@ -146,7 +146,7 @@ class ApiKeyTest < ActiveSupport::TestCase)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)"endtest "should allow user to have new active key after revoking old one" do