mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 22:34:47 +00:00
* Auto-create mobile OAuth application when missing (#912) Self-hosted users who set up their instance without running `db:seed` (or reset their database) got "Record not found" on mobile login because `MobileDevice.shared_oauth_application` used `find_by!` which raises when the "Sure Mobile" Doorkeeper application does not exist. Switch to `find_or_create_by!` so the record is created transparently on first use, matching the attributes from the seed file. * Nice Claude Code suggestion --------- Co-authored-by: Juan José Mata <jjmata@jjmata.com>
24 lines
717 B
Ruby
24 lines
717 B
Ruby
require "test_helper"
|
|
|
|
class MobileDeviceTest < ActiveSupport::TestCase
|
|
setup do
|
|
MobileDevice.instance_variable_set(:@shared_oauth_application, nil)
|
|
end
|
|
|
|
teardown do
|
|
MobileDevice.instance_variable_set(:@shared_oauth_application, nil)
|
|
end
|
|
|
|
test "shared_oauth_application auto-creates application when missing" do
|
|
Doorkeeper::Application.where(name: "Sure Mobile").destroy_all
|
|
|
|
assert_difference("Doorkeeper::Application.count", 1) do
|
|
app = MobileDevice.shared_oauth_application
|
|
assert_equal "Sure Mobile", app.name
|
|
assert_equal MobileDevice::CALLBACK_URL, app.redirect_uri
|
|
assert_equal "read_write", app.scopes.to_s
|
|
assert_not app.confidential
|
|
end
|
|
end
|
|
end
|