diff --git a/config/environments/production.rb b/config/environments/production.rb index 03da7a3..118809e 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -57,7 +57,7 @@ .then { |logger| ActiveSupport::TaggedLogging.new(logger) } # Prepend all log lines with the following tags. - config.log_tags = [:request_id] + config.log_tags = [ :request_id ] # "info" includes generic and useful information about system operation, but avoids logging too much # information to avoid inadvertent exposure of personally identifiable information (PII). If you diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 7cf34d6..5b17091 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -58,12 +58,12 @@ # Configure which authentication keys should be case-insensitive. # These keys will be downcased upon creating or modifying a user and when used # to authenticate or find a user. Default is :email. - config.case_insensitive_keys = [:email] + config.case_insensitive_keys = [ :email ] # Configure which authentication keys should have whitespace stripped. # These keys will have whitespace before and after removed upon creating or # modifying a user and when used to authenticate or find a user. Default is :email. - config.strip_whitespace_keys = [:email] + config.strip_whitespace_keys = [ :email ] # Tell if authentication through request.params is enabled. True by default. # It can be set to an array that will enable params authentication only for the @@ -97,7 +97,7 @@ # Notice that if you are skipping storage for all authentication paths, you # may want to disable generating routes to Devise's sessions controller by # passing skip: :sessions to `devise_for` in your config/routes.rb - config.skip_session_storage = [:http_auth] + config.skip_session_storage = [ :http_auth ] # By default, Devise cleans up the CSRF token on authentication to # avoid CSRF token fixation attacks. This means that, when using AJAX diff --git a/config/initializers/kiqr.rb b/config/initializers/kiqr.rb index e8bac0b..a17041d 100644 --- a/config/initializers/kiqr.rb +++ b/config/initializers/kiqr.rb @@ -13,12 +13,12 @@ # ==> Account attributes # Strong parameters for account. Used for account creation and update. # Affects both personal and team accounts. - config.account_attributes = [:name] + config.account_attributes = [ :name ] # ==> Locales # Configure the available locales in the application. # This is used to validate the locale of the user. - config.available_locales = [:en, :sv] + config.available_locales = [ :en, :sv ] # Default locale # This is used to set the default locale for the application. diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb index 2df5693..d79cd84 100644 --- a/config/initializers/simple_form.rb +++ b/config/initializers/simple_form.rb @@ -18,12 +18,12 @@ b.optional :min_max b.optional :readonly - b.use :hint, wrap_with: {tag: "span", class: "text-xs absolute mx-left absolute right-0 mr-4 text-neutral-400 italic"} + b.use :hint, wrap_with: { tag: "span", class: "text-xs absolute mx-left absolute right-0 mr-4 text-neutral-400 italic" } b.use :label, class: "text-left text-text font-bold text-sm uppercase whitespace-nowrap" b.use :input, class: "text-left appearance-none p-0 m-0 w-full border-0 focus:ring-0 focus:outline-none bg-transparent text-text placeholder-light", error_class: "is-invalid" end - w.use :error, wrap_with: {tag: "div", class: "text-xs text-rose-500 italic pt-1.5 text-left"} + w.use :error, wrap_with: { tag: "div", class: "text-xs text-rose-500 italic pt-1.5 text-left" } end config.wrappers :inline_checkbox, tag: "div", class: "flex items-center gap-x-4 w-full", error_class: "error" do |b| diff --git a/db/migrate/20240325084418_create_accounts.rb b/db/migrate/20240325084418_create_accounts.rb index 9aa9752..babc5f8 100644 --- a/db/migrate/20240325084418_create_accounts.rb +++ b/db/migrate/20240325084418_create_accounts.rb @@ -1,7 +1,7 @@ class CreateAccounts < ActiveRecord::Migration[7.1] def change create_table :accounts do |t| - t.string :public_uid, index: {unique: true} + t.string :public_uid, index: { unique: true } t.string :name, null: false t.boolean :personal, null: false, default: false @@ -9,6 +9,6 @@ def change end # Add a optional personal_account reference to users. - add_reference :users, :personal_account, foreign_key: {to_table: :accounts}, null: true + add_reference :users, :personal_account, foreign_key: { to_table: :accounts }, null: true end end diff --git a/db/migrate/20240407174725_create_account_invitations.rb b/db/migrate/20240407174725_create_account_invitations.rb index 9ea256c..8b85556 100644 --- a/db/migrate/20240407174725_create_account_invitations.rb +++ b/db/migrate/20240407174725_create_account_invitations.rb @@ -1,7 +1,7 @@ class CreateAccountInvitations < ActiveRecord::Migration[7.1] def change create_table :account_invitations do |t| - t.string :public_uid, index: {unique: true} + t.string :public_uid, index: { unique: true } t.references :account, null: false, foreign_key: true t.string :email, null: false t.datetime :accepted_at @@ -10,6 +10,6 @@ def change add_column :accounts, :account_invitations_count, :integer, default: 0 add_index :account_invitations, :email - add_index :account_invitations, [:account_id, :email], unique: true + add_index :account_invitations, [ :account_id, :email ], unique: true end end diff --git a/db/migrate/20240408105555_add_unique_index_to_account_users.rb b/db/migrate/20240408105555_add_unique_index_to_account_users.rb index 0d7f215..7bd3081 100644 --- a/db/migrate/20240408105555_add_unique_index_to_account_users.rb +++ b/db/migrate/20240408105555_add_unique_index_to_account_users.rb @@ -1,5 +1,5 @@ class AddUniqueIndexToAccountUsers < ActiveRecord::Migration[7.1] def change - add_index :account_users, [:account_id, :user_id], unique: true + add_index :account_users, [ :account_id, :user_id ], unique: true end end diff --git a/db/migrate/20240424103325_create_omniauth_identities.rb b/db/migrate/20240424103325_create_omniauth_identities.rb index 8f55967..0232350 100644 --- a/db/migrate/20240424103325_create_omniauth_identities.rb +++ b/db/migrate/20240424103325_create_omniauth_identities.rb @@ -1,7 +1,7 @@ class CreateOmniauthIdentities < ActiveRecord::Migration[7.1] def change create_table :omniauth_identities do |t| - t.string :public_uid, index: {unique: true} + t.string :public_uid, index: { unique: true } t.references :user, foreign_key: true, null: false diff --git a/gems/kiqr-themes-base/kiqr-themes-base.gemspec b/gems/kiqr-themes-base/kiqr-themes-base.gemspec index 563f861..20b01dd 100644 --- a/gems/kiqr-themes-base/kiqr-themes-base.gemspec +++ b/gems/kiqr-themes-base/kiqr-themes-base.gemspec @@ -3,8 +3,8 @@ require_relative "lib/kiqr/themes/base/version" Gem::Specification.new do |spec| spec.name = "kiqr-themes-base" spec.version = Kiqr::Themes::Base::VERSION - spec.authors = ["Rasmus Kjellberg"] - spec.email = ["2277443+kjellberg@users.noreply.github.com"] + spec.authors = [ "Rasmus Kjellberg" ] + spec.email = [ "2277443+kjellberg@users.noreply.github.com" ] spec.homepage = "https://kiqr.dev" spec.summary = "Base theme files for KIQR" spec.description = "Views and assets for KIQR themes." diff --git a/gems/kiqr-themes-base/test/test_helper.rb b/gems/kiqr-themes-base/test/test_helper.rb index 9f2c11d..25a5782 100644 --- a/gems/kiqr-themes-base/test/test_helper.rb +++ b/gems/kiqr-themes-base/test/test_helper.rb @@ -2,12 +2,12 @@ ENV["RAILS_ENV"] = "test" require_relative "../test/dummy/config/environment" -ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)] +ActiveRecord::Migrator.migrations_paths = [ File.expand_path("../test/dummy/db/migrate", __dir__) ] require "rails/test_help" # Load fixtures from the engine if ActiveSupport::TestCase.respond_to?(:fixture_paths=) - ActiveSupport::TestCase.fixture_paths = [File.expand_path("fixtures", __dir__)] + ActiveSupport::TestCase.fixture_paths = [ File.expand_path("fixtures", __dir__) ] ActionDispatch::IntegrationTest.fixture_paths = ActiveSupport::TestCase.fixture_paths ActiveSupport::TestCase.file_fixture_path = File.expand_path("fixtures", __dir__) + "/files" ActiveSupport::TestCase.fixtures :all diff --git a/gems/kiqr-translations/kiqr-translations.gemspec b/gems/kiqr-translations/kiqr-translations.gemspec index 2322980..bf94bc9 100644 --- a/gems/kiqr-translations/kiqr-translations.gemspec +++ b/gems/kiqr-translations/kiqr-translations.gemspec @@ -3,8 +3,8 @@ require_relative "lib/kiqr/translations/version" Gem::Specification.new do |spec| spec.name = "kiqr-translations" spec.version = Kiqr::Translations::VERSION - spec.authors = ["Rasmus Kjellberg"] - spec.email = ["2277443+kjellberg@users.noreply.github.com"] + spec.authors = [ "Rasmus Kjellberg" ] + spec.email = [ "2277443+kjellberg@users.noreply.github.com" ] spec.homepage = "https://kiqr.dev" spec.summary = "Translations for KIQR framework" spec.description = "Includes I18n translations for KIQR framework." diff --git a/gems/kiqr-translations/test/test_helper.rb b/gems/kiqr-translations/test/test_helper.rb index 9f2c11d..25a5782 100644 --- a/gems/kiqr-translations/test/test_helper.rb +++ b/gems/kiqr-translations/test/test_helper.rb @@ -2,12 +2,12 @@ ENV["RAILS_ENV"] = "test" require_relative "../test/dummy/config/environment" -ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)] +ActiveRecord::Migrator.migrations_paths = [ File.expand_path("../test/dummy/db/migrate", __dir__) ] require "rails/test_help" # Load fixtures from the engine if ActiveSupport::TestCase.respond_to?(:fixture_paths=) - ActiveSupport::TestCase.fixture_paths = [File.expand_path("fixtures", __dir__)] + ActiveSupport::TestCase.fixture_paths = [ File.expand_path("fixtures", __dir__) ] ActionDispatch::IntegrationTest.fixture_paths = ActiveSupport::TestCase.fixture_paths ActiveSupport::TestCase.file_fixture_path = File.expand_path("fixtures", __dir__) + "/files" ActiveSupport::TestCase.fixtures :all diff --git a/gems/kiqr/app/controllers/kiqr/invitations_controller.rb b/gems/kiqr/app/controllers/kiqr/invitations_controller.rb index f4460ac..469ec85 100644 --- a/gems/kiqr/app/controllers/kiqr/invitations_controller.rb +++ b/gems/kiqr/app/controllers/kiqr/invitations_controller.rb @@ -1,5 +1,5 @@ class Kiqr::InvitationsController < KiqrController - skip_before_action :authenticate_user!, only: [:show] + skip_before_action :authenticate_user!, only: [ :show ] def show @invitation = AccountInvitation.find_puid!(params[:id]) diff --git a/gems/kiqr/app/controllers/kiqr/registrations_controller.rb b/gems/kiqr/app/controllers/kiqr/registrations_controller.rb index c299092..9dccaf5 100644 --- a/gems/kiqr/app/controllers/kiqr/registrations_controller.rb +++ b/gems/kiqr/app/controllers/kiqr/registrations_controller.rb @@ -1,6 +1,6 @@ class Kiqr::RegistrationsController < Devise::RegistrationsController - skip_before_action :require_no_authentication, only: [:cancel] - before_action :authenticate_user!, only: [:cancel] + skip_before_action :require_no_authentication, only: [ :cancel ] + before_action :authenticate_user!, only: [ :cancel ] def cancel @conflicting_account_users = current_user.account_users.where(owner: true) diff --git a/gems/kiqr/app/controllers/kiqr/sessions_controller.rb b/gems/kiqr/app/controllers/kiqr/sessions_controller.rb index dfcca89..8a6c65f 100644 --- a/gems/kiqr/app/controllers/kiqr/sessions_controller.rb +++ b/gems/kiqr/app/controllers/kiqr/sessions_controller.rb @@ -11,7 +11,7 @@ def new # Override the default Devise create method and check if the user has enabled 2FA # If 2FA is enabled, render the OTP form page. Otherwise, proceed with the default login flow. def otp_authentication - devise_parameter_sanitizer.permit(:sign_in, keys: [:otp_attempt]) + devise_parameter_sanitizer.permit(:sign_in, keys: [ :otp_attempt ]) if sign_in_params[:email] show_otp_code_form diff --git a/gems/kiqr/app/controllers/kiqr_controller.rb b/gems/kiqr/app/controllers/kiqr_controller.rb index e0d91af..f1075c7 100644 --- a/gems/kiqr/app/controllers/kiqr_controller.rb +++ b/gems/kiqr/app/controllers/kiqr_controller.rb @@ -4,7 +4,7 @@ class KiqrController < ApplicationController # Get the options for the locale form select field def options_for_locale I18n.available_locales.map do |locale| - [I18n.t("kiqr.languages.#{locale}"), locale] + [ I18n.t("kiqr.languages.#{locale}"), locale ] end end helper_method :options_for_locale @@ -12,7 +12,7 @@ def options_for_locale # Get the options for time zone form select field def options_for_time_zone ActiveSupport::TimeZone.all.map do |time_zone| - [time_zone.to_s, time_zone.name] + [ time_zone.to_s, time_zone.name ] end end helper_method :options_for_time_zone diff --git a/gems/kiqr/app/models/account.rb b/gems/kiqr/app/models/account.rb index a1cad03..fda4915 100644 --- a/gems/kiqr/app/models/account.rb +++ b/gems/kiqr/app/models/account.rb @@ -7,7 +7,7 @@ class Account < ApplicationRecord include PublicUid::ModelConcern # Name is required with a minimum length of 3 and a maximum length of 255. - validates :name, presence: true, length: {minimum: 3, maximum: 255} + validates :name, presence: true, length: { minimum: 3, maximum: 255 } has_many :account_users, dependent: :destroy has_many :account_invitations, dependent: :destroy diff --git a/gems/kiqr/app/models/account_invitation.rb b/gems/kiqr/app/models/account_invitation.rb index d0b5993..12a77f1 100644 --- a/gems/kiqr/app/models/account_invitation.rb +++ b/gems/kiqr/app/models/account_invitation.rb @@ -11,8 +11,8 @@ class AccountInvitation < ApplicationRecord belongs_to :account, inverse_of: :account_invitations, counter_cache: true - validates :email, presence: true, format: {with: URI::MailTo::EMAIL_REGEXP} - validates :email, uniqueness: {scope: :account_id, message: I18n.t("kiqr.accounts.invitations.errors.email_taken")} + validates :email, presence: true, format: { with: URI::MailTo::EMAIL_REGEXP } + validates :email, uniqueness: { scope: :account_id, message: I18n.t("kiqr.accounts.invitations.errors.email_taken") } scope :pending, -> { where(accepted_at: nil) } end diff --git a/gems/kiqr/app/models/omniauth_identity.rb b/gems/kiqr/app/models/omniauth_identity.rb index 73f8338..732d86d 100644 --- a/gems/kiqr/app/models/omniauth_identity.rb +++ b/gems/kiqr/app/models/omniauth_identity.rb @@ -15,7 +15,7 @@ class OmniauthIdentity < ApplicationRecord # Find an omniauth_identity by its provider and a uid. def self.from_payload(payload) - args = {provider: payload.provider, provider_uid: payload.uid} + args = { provider: payload.provider, provider_uid: payload.uid } where(args).first || new(args) end end diff --git a/gems/kiqr/app/models/user.rb b/gems/kiqr/app/models/user.rb index c47f8d1..edb84b2 100644 --- a/gems/kiqr/app/models/user.rb +++ b/gems/kiqr/app/models/user.rb @@ -17,10 +17,10 @@ class User < ApplicationRecord validates :email, presence: true, uniqueness: true # Validate time zone format. - validates :time_zone, inclusion: {in: ActiveSupport::TimeZone.all.map(&:name)} + validates :time_zone, inclusion: { in: ActiveSupport::TimeZone.all.map(&:name) } # Validate locale is a valid locale. - validates :locale, inclusion: {in: Kiqr::Config.available_locales.map(&:to_s)} + validates :locale, inclusion: { in: Kiqr::Config.available_locales.map(&:to_s) } # Get the user's full name from their personal account. delegate :name, to: :personal_account diff --git a/gems/kiqr/config/initializers/devise.rb b/gems/kiqr/config/initializers/devise.rb index 7cf34d6..5b17091 100644 --- a/gems/kiqr/config/initializers/devise.rb +++ b/gems/kiqr/config/initializers/devise.rb @@ -58,12 +58,12 @@ # Configure which authentication keys should be case-insensitive. # These keys will be downcased upon creating or modifying a user and when used # to authenticate or find a user. Default is :email. - config.case_insensitive_keys = [:email] + config.case_insensitive_keys = [ :email ] # Configure which authentication keys should have whitespace stripped. # These keys will have whitespace before and after removed upon creating or # modifying a user and when used to authenticate or find a user. Default is :email. - config.strip_whitespace_keys = [:email] + config.strip_whitespace_keys = [ :email ] # Tell if authentication through request.params is enabled. True by default. # It can be set to an array that will enable params authentication only for the @@ -97,7 +97,7 @@ # Notice that if you are skipping storage for all authentication paths, you # may want to disable generating routes to Devise's sessions controller by # passing skip: :sessions to `devise_for` in your config/routes.rb - config.skip_session_storage = [:http_auth] + config.skip_session_storage = [ :http_auth ] # By default, Devise cleans up the CSRF token on authentication to # avoid CSRF token fixation attacks. This means that, when using AJAX diff --git a/gems/kiqr/db/migrate/20240325084418_create_accounts.rb b/gems/kiqr/db/migrate/20240325084418_create_accounts.rb index 9aa9752..babc5f8 100644 --- a/gems/kiqr/db/migrate/20240325084418_create_accounts.rb +++ b/gems/kiqr/db/migrate/20240325084418_create_accounts.rb @@ -1,7 +1,7 @@ class CreateAccounts < ActiveRecord::Migration[7.1] def change create_table :accounts do |t| - t.string :public_uid, index: {unique: true} + t.string :public_uid, index: { unique: true } t.string :name, null: false t.boolean :personal, null: false, default: false @@ -9,6 +9,6 @@ def change end # Add a optional personal_account reference to users. - add_reference :users, :personal_account, foreign_key: {to_table: :accounts}, null: true + add_reference :users, :personal_account, foreign_key: { to_table: :accounts }, null: true end end diff --git a/gems/kiqr/db/migrate/20240407174725_create_account_invitations.rb b/gems/kiqr/db/migrate/20240407174725_create_account_invitations.rb index 9ea256c..8b85556 100644 --- a/gems/kiqr/db/migrate/20240407174725_create_account_invitations.rb +++ b/gems/kiqr/db/migrate/20240407174725_create_account_invitations.rb @@ -1,7 +1,7 @@ class CreateAccountInvitations < ActiveRecord::Migration[7.1] def change create_table :account_invitations do |t| - t.string :public_uid, index: {unique: true} + t.string :public_uid, index: { unique: true } t.references :account, null: false, foreign_key: true t.string :email, null: false t.datetime :accepted_at @@ -10,6 +10,6 @@ def change add_column :accounts, :account_invitations_count, :integer, default: 0 add_index :account_invitations, :email - add_index :account_invitations, [:account_id, :email], unique: true + add_index :account_invitations, [ :account_id, :email ], unique: true end end diff --git a/gems/kiqr/db/migrate/20240408105555_add_unique_index_to_account_users.rb b/gems/kiqr/db/migrate/20240408105555_add_unique_index_to_account_users.rb index 0d7f215..7bd3081 100644 --- a/gems/kiqr/db/migrate/20240408105555_add_unique_index_to_account_users.rb +++ b/gems/kiqr/db/migrate/20240408105555_add_unique_index_to_account_users.rb @@ -1,5 +1,5 @@ class AddUniqueIndexToAccountUsers < ActiveRecord::Migration[7.1] def change - add_index :account_users, [:account_id, :user_id], unique: true + add_index :account_users, [ :account_id, :user_id ], unique: true end end diff --git a/gems/kiqr/db/migrate/20240424103325_create_omniauth_identities.rb b/gems/kiqr/db/migrate/20240424103325_create_omniauth_identities.rb index 8f55967..0232350 100644 --- a/gems/kiqr/db/migrate/20240424103325_create_omniauth_identities.rb +++ b/gems/kiqr/db/migrate/20240424103325_create_omniauth_identities.rb @@ -1,7 +1,7 @@ class CreateOmniauthIdentities < ActiveRecord::Migration[7.1] def change create_table :omniauth_identities do |t| - t.string :public_uid, index: {unique: true} + t.string :public_uid, index: { unique: true } t.references :user, foreign_key: true, null: false diff --git a/gems/kiqr/kiqr.gemspec b/gems/kiqr/kiqr.gemspec index d0bff93..3e66a14 100644 --- a/gems/kiqr/kiqr.gemspec +++ b/gems/kiqr/kiqr.gemspec @@ -3,8 +3,8 @@ require_relative "lib/kiqr/version" Gem::Specification.new do |spec| spec.name = "kiqr" spec.version = Kiqr::VERSION - spec.authors = ["Rasmus Kjellberg"] - spec.email = ["2277443+kjellberg@users.noreply.github.com"] + spec.authors = [ "Rasmus Kjellberg" ] + spec.email = [ "2277443+kjellberg@users.noreply.github.com" ] spec.homepage = "https://kiqr.dev" spec.summary = "SaaS framework for Rails" spec.description = "KIQR is a complete solution to kickstart your SaaS development." diff --git a/gems/kiqr/lib/kiqr/config.rb b/gems/kiqr/lib/kiqr/config.rb index 1afc2af..8ae1d86 100644 --- a/gems/kiqr/lib/kiqr/config.rb +++ b/gems/kiqr/lib/kiqr/config.rb @@ -16,12 +16,12 @@ class Config # ==> Account attributes # Strong parameters for account. Used for account creation and update. # Affects both personal and team accounts. - config_accessor :account_attributes, default: [:name] + config_accessor :account_attributes, default: [ :name ] # ==> Locales # Configure the available locales in the application. # This is used to validate the locale of the user. - config_accessor :available_locales, default: [:en, :sv] + config_accessor :available_locales, default: [ :en, :sv ] # Default locale # This is used to set the default locale for the application. diff --git a/gems/kiqr/lib/kiqr/framework.rb b/gems/kiqr/lib/kiqr/framework.rb index b7fa40f..c9582fa 100644 --- a/gems/kiqr/lib/kiqr/framework.rb +++ b/gems/kiqr/lib/kiqr/framework.rb @@ -24,7 +24,7 @@ def kiqr_flash_message(type, message, **) # This is used to ensure that all routes are scoped to the current team. Personal account # routes are not affected. def default_url_options - {account_id: params[:account_id]} + { account_id: params[:account_id] } end # Redirect to onboarding if user is not onboarded diff --git a/gems/kiqr/lib/kiqr/rails/routes.rb b/gems/kiqr/lib/kiqr/rails/routes.rb index b819149..6b0fdb6 100644 --- a/gems/kiqr/lib/kiqr/rails/routes.rb +++ b/gems/kiqr/lib/kiqr/rails/routes.rb @@ -64,18 +64,18 @@ def omniauth_routes(options) # => Account routes def account_routes(options) - resources :accounts, controller: options[:controllers][:accounts], only: [:new, :create] + resources :accounts, controller: options[:controllers][:accounts], only: [ :new, :create ] get "select-account", controller: options[:controllers][:accounts], action: :select, as: :select_account scope "(/team/:account_id)", account_id: %r{[^/]+} do - resource :account, only: [:edit, :update], controller: options[:controllers][:accounts] - resources :account_users, controller: options[:controllers][:account_users], only: [:index, :edit, :update, :destroy], path: "members" + resource :account, only: [ :edit, :update ], controller: options[:controllers][:accounts] + resources :account_users, controller: options[:controllers][:account_users], only: [ :index, :edit, :update, :destroy ], path: "members" end end # => Authentication routes def devise_routes(options) - devise_for :users, path_names: {sign_in: "login", sign_up: "create-account"}, controllers: { + devise_for :users, path_names: { sign_in: "login", sign_up: "create-account" }, controllers: { registrations: options[:controllers][:registrations], sessions: options[:controllers][:sessions] } @@ -105,7 +105,7 @@ def invitation_routes(options) # Inviter teamable_scope do - resources :account_invitations, controller: "kiqr/accounts/invitations", only: [:index, :new, :create, :destroy] + resources :account_invitations, controller: "kiqr/accounts/invitations", only: [ :index, :new, :create, :destroy ] end end diff --git a/gems/kiqr/test/dummy/config/environments/production.rb b/gems/kiqr/test/dummy/config/environments/production.rb index 62da9b5..8933ac0 100644 --- a/gems/kiqr/test/dummy/config/environments/production.rb +++ b/gems/kiqr/test/dummy/config/environments/production.rb @@ -57,7 +57,7 @@ .then { |logger| ActiveSupport::TaggedLogging.new(logger) } # Prepend all log lines with the following tags. - config.log_tags = [:request_id] + config.log_tags = [ :request_id ] # "info" includes generic and useful information about system operation, but avoids logging too much # information to avoid inadvertent exposure of personally identifiable information (PII). If you diff --git a/gems/kiqr/test/dummy/db/schema.rb b/gems/kiqr/test/dummy/db/schema.rb index 1e14bd0..49ecced 100644 --- a/gems/kiqr/test/dummy/db/schema.rb +++ b/gems/kiqr/test/dummy/db/schema.rb @@ -18,10 +18,10 @@ t.datetime "accepted_at" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.index ["account_id", "email"], name: "index_account_invitations_on_account_id_and_email", unique: true - t.index ["account_id"], name: "index_account_invitations_on_account_id" - t.index ["email"], name: "index_account_invitations_on_email" - t.index ["public_uid"], name: "index_account_invitations_on_public_uid", unique: true + t.index [ "account_id", "email" ], name: "index_account_invitations_on_account_id_and_email", unique: true + t.index [ "account_id" ], name: "index_account_invitations_on_account_id" + t.index [ "email" ], name: "index_account_invitations_on_email" + t.index [ "public_uid" ], name: "index_account_invitations_on_public_uid", unique: true end create_table "account_users", force: :cascade do |t| @@ -31,10 +31,10 @@ t.datetime "updated_at", null: false t.string "public_uid" t.boolean "owner", default: false, null: false - t.index ["account_id", "user_id"], name: "index_account_users_on_account_id_and_user_id", unique: true - t.index ["account_id"], name: "index_account_users_on_account_id" - t.index ["public_uid"], name: "index_account_users_on_public_uid", unique: true - t.index ["user_id"], name: "index_account_users_on_user_id" + t.index [ "account_id", "user_id" ], name: "index_account_users_on_account_id_and_user_id", unique: true + t.index [ "account_id" ], name: "index_account_users_on_account_id" + t.index [ "public_uid" ], name: "index_account_users_on_public_uid", unique: true + t.index [ "user_id" ], name: "index_account_users_on_user_id" end create_table "accounts", force: :cascade do |t| @@ -44,7 +44,7 @@ t.datetime "created_at", null: false t.datetime "updated_at", null: false t.integer "account_invitations_count", default: 0 - t.index ["public_uid"], name: "index_accounts_on_public_uid", unique: true + t.index [ "public_uid" ], name: "index_accounts_on_public_uid", unique: true end create_table "omniauth_identities", force: :cascade do |t| @@ -58,8 +58,8 @@ t.datetime "expires_at" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.index ["public_uid"], name: "index_omniauth_identities_on_public_uid", unique: true - t.index ["user_id"], name: "index_omniauth_identities_on_user_id" + t.index [ "public_uid" ], name: "index_omniauth_identities_on_public_uid", unique: true + t.index [ "user_id" ], name: "index_omniauth_identities_on_user_id" end create_table "users", force: :cascade do |t| @@ -89,11 +89,11 @@ t.text "otp_backup_codes" t.string "locale", default: "en" t.string "time_zone", default: "UTC" - t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true - t.index ["email"], name: "index_users_on_email", unique: true - t.index ["personal_account_id"], name: "index_users_on_personal_account_id" - t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true - t.index ["unlock_token"], name: "index_users_on_unlock_token", unique: true + t.index [ "confirmation_token" ], name: "index_users_on_confirmation_token", unique: true + t.index [ "email" ], name: "index_users_on_email", unique: true + t.index [ "personal_account_id" ], name: "index_users_on_personal_account_id" + t.index [ "reset_password_token" ], name: "index_users_on_reset_password_token", unique: true + t.index [ "unlock_token" ], name: "index_users_on_unlock_token", unique: true end add_foreign_key "account_invitations", "accounts" diff --git a/gems/kiqr/test/routing_test.rb b/gems/kiqr/test/routing_test.rb index 5e09332..d078a44 100644 --- a/gems/kiqr/test/routing_test.rb +++ b/gems/kiqr/test/routing_test.rb @@ -9,15 +9,15 @@ class RoutingTest < ActionDispatch::IntegrationTest end test "kiqr routes setup default controllers" do - assert_recognizes({controller: "kiqr/accounts", action: "new"}, "/accounts/new") - assert_recognizes({controller: "kiqr/accounts", action: "select"}, "/select-account") + assert_recognizes({ controller: "kiqr/accounts", action: "new" }, "/accounts/new") + assert_recognizes({ controller: "kiqr/accounts", action: "select" }, "/select-account") # assert_recognizes({controller: "users/sessions", action: "new"}, "/users/login") end test "account routes are correctly configured" do - assert_routing "/accounts/new", {controller: "kiqr/accounts", action: "new"} - assert_routing "/select-account", {controller: "kiqr/accounts", action: "select"} - assert_routing({method: "post", path: "/accounts"}, {controller: "kiqr/accounts", action: "create"}) + assert_routing "/accounts/new", { controller: "kiqr/accounts", action: "new" } + assert_routing "/select-account", { controller: "kiqr/accounts", action: "select" } + assert_routing({ method: "post", path: "/accounts" }, { controller: "kiqr/accounts", action: "create" }) end # test "devise routes for users are correctly configured" do diff --git a/gems/kiqr/test/test_helper.rb b/gems/kiqr/test/test_helper.rb index 1b67172..9391124 100644 --- a/gems/kiqr/test/test_helper.rb +++ b/gems/kiqr/test/test_helper.rb @@ -11,7 +11,7 @@ end require_relative "../test/dummy/config/environment" -ActiveRecord::Migrator.migrations_paths = [File.expand_path("../db/migrate", __dir__)] +ActiveRecord::Migrator.migrations_paths = [ File.expand_path("../db/migrate", __dir__) ] require "rails/test_help" FactoryBot.find_definitions diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index b91828c..bbcd471 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -1,5 +1,5 @@ require "test_helper" class ApplicationSystemTestCase < ActionDispatch::SystemTestCase - driven_by :selenium, using: (ENV["CI"] ? :headless_chrome : :chrome), screen_size: [1400, 1400] + driven_by :selenium, using: (ENV["CI"] ? :headless_chrome : :chrome), screen_size: [ 1400, 1400 ] end diff --git a/test/controllers/kiqr/accounts/invitations_controller_test.rb b/test/controllers/kiqr/accounts/invitations_controller_test.rb index 0a9121b..dd794a3 100644 --- a/test/controllers/kiqr/accounts/invitations_controller_test.rb +++ b/test/controllers/kiqr/accounts/invitations_controller_test.rb @@ -9,7 +9,7 @@ class InvitationsControllerTest < ActionDispatch::IntegrationTest sign_in user assert_difference -> { account.account_invitations.count } do - post account_invitations_path(account_id: account), params: {account_invitation: {email: "foobar@agag.com"}} + post account_invitations_path(account_id: account), params: { account_invitation: { email: "foobar@agag.com" } } end assert_redirected_to account_invitations_path(account_id: account) @@ -25,7 +25,7 @@ class InvitationsControllerTest < ActionDispatch::IntegrationTest sign_in user assert_raises(PublicUid::RecordNotFound) do - post account_invitations_path(account_id: foreign_account), params: {account_invitation: {email: "foobar@agag.com"}} + post account_invitations_path(account_id: foreign_account), params: { account_invitation: { email: "foobar@agag.com" } } end end @@ -36,11 +36,11 @@ class InvitationsControllerTest < ActionDispatch::IntegrationTest sign_in user - post account_invitations_path(account_id: account), params: {account_invitation: {email: "foobar@foobar.com"}} + post account_invitations_path(account_id: account), params: { account_invitation: { email: "foobar@foobar.com" } } assert_redirected_to account_invitations_path(account_id: account) assert_no_difference -> { account.account_invitations.count } do - post account_invitations_path(account_id: account), params: {account_invitation: {email: "foobar@foobar.com"}} + post account_invitations_path(account_id: account), params: { account_invitation: { email: "foobar@foobar.com" } } end end @@ -52,7 +52,7 @@ class InvitationsControllerTest < ActionDispatch::IntegrationTest sign_in user assert_no_difference -> { account.account_invitations.count } do - post account_invitations_path(account_id: account), params: {account_invitation: {email: "foo"}} + post account_invitations_path(account_id: account), params: { account_invitation: { email: "foo" } } end assert_response :unprocessable_entity diff --git a/test/controllers/kiqr/accounts_controller_test.rb b/test/controllers/kiqr/accounts_controller_test.rb index f6ccea4..c071e91 100644 --- a/test/controllers/kiqr/accounts_controller_test.rb +++ b/test/controllers/kiqr/accounts_controller_test.rb @@ -17,7 +17,7 @@ class Kiqr::AccountsControllerTest < ActionDispatch::IntegrationTest user = create(:user) sign_in user - post accounts_path, params: {account: {name: "Foobar team"}} + post accounts_path, params: { account: { name: "Foobar team" } } new_team = Account.find_by(name: "Foobar team") assert_redirected_to dashboard_path(account_id: Account.last) @@ -28,7 +28,7 @@ class Kiqr::AccountsControllerTest < ActionDispatch::IntegrationTest user = create(:user) sign_in user - post accounts_path, params: {account: {name: "no"}} + post accounts_path, params: { account: { name: "no" } } assert_response :unprocessable_entity # assert_template :new end @@ -39,7 +39,7 @@ class Kiqr::AccountsControllerTest < ActionDispatch::IntegrationTest account.account_users << AccountUser.create(user:, owner: true) sign_in user - patch account_path(account_id: account), params: {account: {name: "New company name"}} + patch account_path(account_id: account), params: { account: { name: "New company name" } } account.reload assert_redirected_to edit_account_path @@ -53,7 +53,7 @@ class Kiqr::AccountsControllerTest < ActionDispatch::IntegrationTest sign_in user - patch account_path(account_id: account), params: {account: {name: "no"}} + patch account_path(account_id: account), params: { account: { name: "no" } } assert_response :unprocessable_entity end end diff --git a/test/controllers/kiqr/onboarding_controller_test.rb b/test/controllers/kiqr/onboarding_controller_test.rb index c44033d..7fa578f 100644 --- a/test/controllers/kiqr/onboarding_controller_test.rb +++ b/test/controllers/kiqr/onboarding_controller_test.rb @@ -16,14 +16,14 @@ class Kiqr::OnboardingControllerTest < ActionDispatch::IntegrationTest test "can onboard user" do user = create(:user, personal_account: nil) sign_in user - post onboarding_path, params: {user: {personal_account_attributes: {name: "Foobar zoo"}}} + post onboarding_path, params: { user: { personal_account_attributes: { name: "Foobar zoo" } } } assert_redirected_to dashboard_path assert user.reload.personal_account.personal? end test "validates user onboarding" do sign_in create(:user, personal_account: nil) - post onboarding_path, params: {user: {personal_account_attributes: {name: "no"}}} + post onboarding_path, params: { user: { personal_account_attributes: { name: "no" } } } assert_response :unprocessable_entity assert_template :new end diff --git a/test/controllers/kiqr/sessions_controller_test.rb b/test/controllers/kiqr/sessions_controller_test.rb index db432ce..75f587a 100644 --- a/test/controllers/kiqr/sessions_controller_test.rb +++ b/test/controllers/kiqr/sessions_controller_test.rb @@ -3,38 +3,38 @@ class Kiqr::SessionsControllerTest < ActionDispatch::IntegrationTest test "can sign in if two factor is disabled" do user = create(:user) - post user_session_path, params: {user: {email: user.email, password: user.password}} + post user_session_path, params: { user: { email: user.email, password: user.password } } assert_response :redirect assert_redirected_to dashboard_path end test "can sign in with otp if two factor is enabled" do user = create(:user, :otp_enabled) - post user_session_path, params: {user: {email: user.email, password: user.password}} + post user_session_path, params: { user: { email: user.email, password: user.password } } assert_response :unprocessable_entity assert_template "kiqr/sessions/otp" - post user_session_path, params: {user: {otp_attempt: user.current_otp}} + post user_session_path, params: { user: { otp_attempt: user.current_otp } } assert_redirected_to dashboard_path end test "can't sign in with invalid otp if two factor is enabled" do user = create(:user, :otp_enabled) - post user_session_path, params: {user: {email: user.email, password: user.password}} - post user_session_path, params: {user: {otp_attempt: "123456"}} + post user_session_path, params: { user: { email: user.email, password: user.password } } + post user_session_path, params: { user: { otp_attempt: "123456" } } assert_response :unprocessable_entity assert_template "kiqr/sessions/otp" end test "renders form again if invalid email" do - post user_session_path, params: {user: {email: "unknown.email", password: "randompassword"}} + post user_session_path, params: { user: { email: "unknown.email", password: "randompassword" } } assert_response :unprocessable_entity assert_template "kiqr/sessions/new" end test "renders form again if invalid password" do user = create(:user) - post user_session_path, params: {user: {email: user.email, password: "randompassword"}} + post user_session_path, params: { user: { email: user.email, password: "randompassword" } } assert_response :unprocessable_entity assert_template "kiqr/sessions/new" end diff --git a/test/controllers/kiqr/settings_controller_test.rb b/test/controllers/kiqr/settings_controller_test.rb index a16a846..0ccfee7 100644 --- a/test/controllers/kiqr/settings_controller_test.rb +++ b/test/controllers/kiqr/settings_controller_test.rb @@ -12,7 +12,7 @@ class Kiqr::PreferencesControllerTest < ActionDispatch::IntegrationTest user = create(:user, time_zone: "UTC", locale: "en") sign_in(user) - patch settings_path, params: {user: {time_zone: "Stockholm", locale: "sv"}} + patch settings_path, params: { user: { time_zone: "Stockholm", locale: "sv" } } assert_redirected_to edit_settings_path assert_equal "Stockholm", user.reload.time_zone assert_equal "sv", user.reload.locale @@ -22,7 +22,7 @@ class Kiqr::PreferencesControllerTest < ActionDispatch::IntegrationTest user = create(:user) sign_in user - patch settings_path, params: {user: {personal_account_attributes: {name: "Personal account name"}}} + patch settings_path, params: { user: { personal_account_attributes: { name: "Personal account name" } } } user.reload assert_redirected_to edit_settings_path diff --git a/test/controllers/kiqr/two_factor_controller_test.rb b/test/controllers/kiqr/two_factor_controller_test.rb index 2238639..81845e8 100644 --- a/test/controllers/kiqr/two_factor_controller_test.rb +++ b/test/controllers/kiqr/two_factor_controller_test.rb @@ -38,14 +38,14 @@ class Kiqr::TwoFactorControllerTest < ActionDispatch::IntegrationTest test "does not activate 2fa with invalid verification code" do user = create(:user, otp_secret: User.generate_otp_secret) sign_in user - post verify_two_factor_path, params: {user: {otp_attempt: "123456"}} + post verify_two_factor_path, params: { user: { otp_attempt: "123456" } } assert_response :unprocessable_entity end test "activates 2fa with valid verification code" do user = create(:user, otp_secret: User.generate_otp_secret) sign_in user - post verify_two_factor_path, params: {user: {otp_attempt: user.current_otp}} + post verify_two_factor_path, params: { user: { otp_attempt: user.current_otp } } assert_redirected_to edit_two_factor_path end @@ -53,12 +53,12 @@ class Kiqr::TwoFactorControllerTest < ActionDispatch::IntegrationTest user = create(:user, :otp_enabled) sign_in user - delete destroy_two_factor_path, params: {user: {otp_attempt: "123456"}} + delete destroy_two_factor_path, params: { user: { otp_attempt: "123456" } } assert_response :unprocessable_entity assert_template "two_factor/disable" assert user.reload.otp_required_for_login? - delete destroy_two_factor_path, params: {user: {otp_attempt: user.current_otp}} + delete destroy_two_factor_path, params: { user: { otp_attempt: user.current_otp } } assert_redirected_to edit_two_factor_path assert_not user.reload.otp_required_for_login? end diff --git a/test/kiqr_test.rb b/test/kiqr_test.rb index 087e102..c8d218b 100644 --- a/test/kiqr_test.rb +++ b/test/kiqr_test.rb @@ -2,12 +2,12 @@ class KiqrTest < ActiveSupport::TestCase test "should set default_url_options to localhost:3000 in test environment" do - assert_equal Kiqr.default_url_options, {host: "localhost", port: 3000, protocol: "http"} + assert_equal Kiqr.default_url_options, { host: "localhost", port: 3000, protocol: "http" } end test "it can override default_url_options with ENV['BASE_URL']" do ENV["BASE_URL"] = "https://example.com" - assert_equal Kiqr.default_url_options, {host: "example.com", protocol: "https"} + assert_equal Kiqr.default_url_options, { host: "example.com", protocol: "https" } ENV["BASE_URL"] = nil end