diff --git a/app/controllers/authentications/google_oauth_controller.rb b/app/controllers/authentications/google_oauth_controller.rb index af070aa1e..3d8a83fd3 100644 --- a/app/controllers/authentications/google_oauth_controller.rb +++ b/app/controllers/authentications/google_oauth_controller.rb @@ -97,7 +97,7 @@ def initialize_google_person def add_person_credentials(type) p = Current.person || @person c = p.user.credentials.build( - type: type, + type:, oauth_id: auth[:uid], oauth_email: auth[:info][:email], oauth_token: auth[:credentials][:token], diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1e2f0d02e..e6e15f20f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -70,15 +70,15 @@ def div_tag(content_or_options_with_block = nil, options = nil, &block) end def meta_tag(name, content) - tag.meta(name: name, content: content) + tag.meta(name:, content:) end def charset_tag(charset) - tag.meta(charset: charset) + tag.meta(charset:) end def viewport_tag(content) - tag.meta(name: "viewport", content: content) + tag.meta(name: "viewport", content:) end def n_a_if_blank(value, n_a = "Not Available") @@ -86,6 +86,6 @@ def n_a_if_blank(value, n_a = "Not Available") end def to_dollars(cents, precision: 2) - number_to_currency(cents / 100.0, precision: precision) + number_to_currency(cents / 100.0, precision:) end end diff --git a/app/jobs/get_next_ai_message_job.rb b/app/jobs/get_next_ai_message_job.rb index 74a68b1d9..013831249 100644 --- a/app/jobs/get_next_ai_message_job.rb +++ b/app/jobs/get_next_ai_message_job.rb @@ -118,7 +118,7 @@ def self.broadcast_updated_message(message, locals = {}) html = ApplicationController.render( partial: "messages/message", locals: { - message: message, + message:, only_scroll_down_if_was_bottom: true, streamed: true, message_counter: message.index diff --git a/app/jobs/send_reset_password_email_job.rb b/app/jobs/send_reset_password_email_job.rb index 371de716b..e7fc1f5bd 100644 --- a/app/jobs/send_reset_password_email_job.rb +++ b/app/jobs/send_reset_password_email_job.rb @@ -7,7 +7,7 @@ def perform(email, os, browser) Rails.logger.info "Sending reset password email to #{email} from #{os} with #{browser}" if person&.user # make sure the user exists (i.e. user has not become a tombstone) - PasswordMailer.with(person: person, os: os, browser: browser).reset.deliver_now + PasswordMailer.with(person:, os:, browser:).reset.deliver_now end end end diff --git a/app/mailers/password_mailer.rb b/app/mailers/password_mailer.rb index 0360a5352..5b729f8b8 100644 --- a/app/mailers/password_mailer.rb +++ b/app/mailers/password_mailer.rb @@ -11,7 +11,7 @@ def reset purpose: Email::PasswordReset::TOKEN_PURPOSE, expires_in: @token_ttl ) - @edit_url = edit_password_credential_url(token: token) + @edit_url = edit_password_credential_url(token:) mail( to: person.email, diff --git a/app/models/message/version.rb b/app/models/message/version.rb index 5baa5fa9e..8c1659ab9 100644 --- a/app/models/message/version.rb +++ b/app/models/message/version.rb @@ -81,9 +81,9 @@ def set_next_conversation_index_and_version else if version.negative? || version > max_version errors.add(:version, "#{version} is invalid for this index") - elsif conversation.messages.exists?(index: index, version: version) + elsif conversation.messages.exists?(index:, version:) errors.add(:version, "#{version} already exists for this index") - elsif versions.present? && version < versions.max && !conversation.messages.exists?(index: index-1, version: version) + elsif versions.present? && version < versions.max && !conversation.messages.exists?(index: index-1, version:) errors.add(:version, "#{version} is invalid for this index") end end diff --git a/app/services/ai_backend.rb b/app/services/ai_backend.rb index 42e4fd7d8..d4204f084 100644 --- a/app/services/ai_backend.rb +++ b/app/services/ai_backend.rb @@ -14,9 +14,9 @@ def initialize(user, assistant, conversation = nil, message = nil) def get_oneoff_message(instructions, messages, params = {}) set_client_config( - instructions: instructions, + instructions:, messages: preceding_messages(messages), - params: params, + params:, ) response = @client.send(client_method_name, ** @client_config) @@ -77,7 +77,7 @@ def preceding_messages(messages = []) role = (i % 2).zero? ? "user" : "assistant" { - role: role, + role:, content: msg } end diff --git a/app/services/ai_backend/open_ai.rb b/app/services/ai_backend/open_ai.rb index 0109d7ca5..5f7146c80 100644 --- a/app/services/ai_backend/open_ai.rb +++ b/app/services/ai_backend/open_ai.rb @@ -88,7 +88,7 @@ def stream_handler(&chunk_handler) def system_message(content) [{ role: "system", - content: content, + content:, }] end diff --git a/app/services/sdk.rb b/app/services/sdk.rb index d073c81bd..238a038c8 100644 --- a/app/services/sdk.rb +++ b/app/services/sdk.rb @@ -1,40 +1,40 @@ class SDK def get(url, token = nil) SDK::Get.new( - url: url, + url:, bearer_token: token || bearer_token, - expected_status: expected_status, - header: header, + expected_status:, + header:, calling_method: calling_method(__method__), ) end def post(url, token = nil) SDK::Post.new( - url: url, + url:, bearer_token: token || bearer_token, - expected_status: expected_status, - header: header, + expected_status:, + header:, calling_method: calling_method(__method__), ) end def patch(url, token = nil) SDK::Patch.new( - url: url, + url:, bearer_token: token || bearer_token, - expected_status: expected_status, - header: header, + expected_status:, + header:, calling_method: calling_method(__method__), ) end def delete(url, token = nil) SDK::Delete.new( - url: url, + url:, bearer_token: token || bearer_token, - expected_status: expected_status, - header: header, + expected_status:, + header:, calling_method: calling_method(__method__), ) end diff --git a/app/services/toolbox/gmail/message.rb b/app/services/toolbox/gmail/message.rb index 5a26a5040..20468e0a3 100644 --- a/app/services/toolbox/gmail/message.rb +++ b/app/services/toolbox/gmail/message.rb @@ -55,13 +55,13 @@ def body_html def to_h { - id: id, - thread_id: thread_id, - date: date, - from: from, - to: to, - subject: subject, - snippet: snippet, + id:, + thread_id:, + date:, + from:, + to:, + subject:, + snippet:, body: body || body_html, } end diff --git a/app/services/toolbox/google_tasks/api_helpers.rb b/app/services/toolbox/google_tasks/api_helpers.rb index 8a56bbf11..4e6bfb86a 100644 --- a/app/services/toolbox/google_tasks/api_helpers.rb +++ b/app/services/toolbox/google_tasks/api_helpers.rb @@ -41,8 +41,8 @@ def get_tasks_for_list(list, due_min: nil, due_max: nil) def create_task_for_list(list, title:, notes: nil, due: nil) refresh_token_if_needed do post("https://tasks.googleapis.com/tasks/v1/lists/#{list.id}/tasks").param( - title: title, - notes: notes, + title:, + notes:, due: format_time(due), status: "needsAction", ) @@ -58,7 +58,7 @@ def move_task_to_list(task, list, keep_due: true) delete_task(task) create_task_for_list(list, title: task.title, - notes: notes, + notes:, due: keep_due.presence && task.try(:due), ) end @@ -73,12 +73,12 @@ def update_task(task, title: nil, notes: nil, due: nil, completed: nil, deleted: refresh_token_if_needed do patch("https://tasks.googleapis.com/tasks/v1/lists/#{list_id_of(task)}/tasks/#{task.id}").param( { id: task.id, - title: title, - notes: notes, + title:, + notes:, due: format_time(due), status: !!completed ? "completed" : "needsAction", completed: completed.presence && format_time(completed), - deleted: deleted, + deleted:, }.compact) # w/o this it updates values to nil end end diff --git a/lib/active_storage/service/postgresql_service.rb b/lib/active_storage/service/postgresql_service.rb index e4d46646a..cb382d12c 100644 --- a/lib/active_storage/service/postgresql_service.rb +++ b/lib/active_storage/service/postgresql_service.rb @@ -7,14 +7,14 @@ def initialize(public: false, **options) end def upload(key, io, checksum: nil, **) - instrument :upload, key: key, checksum: checksum do - ActiveStorage::Postgresql::File.create!(key: key, io: io, checksum: checksum) + instrument :upload, key:, checksum: do + ActiveStorage::Postgresql::File.create!(key:, io:, checksum:) end end def download(key) if block_given? - instrument :streaming_download, key: key do + instrument :streaming_download, key: do ActiveStorage::Postgresql::File.open(key) do |file| while data = file.read(5.megabytes) yield data @@ -22,7 +22,7 @@ def download(key) end end else - instrument :download, key: key do + instrument :download, key: do ActiveStorage::Postgresql::File.open(key) do |file| file.read end @@ -31,7 +31,7 @@ def download(key) end def download_chunk(key, range) - instrument :download_chunk, key: key, range: range do + instrument :download_chunk, key:, range: do ActiveStorage::Postgresql::File.open(key) do |file| file.seek(range.first) file.read(range.size) @@ -40,14 +40,14 @@ def download_chunk(key, range) end def delete(key) - instrument :delete, key: key do - ActiveStorage::Postgresql::File.find_by(key: key).try(&:destroy) + instrument :delete, key: do + ActiveStorage::Postgresql::File.find_by(key:).try(&:destroy) end end def exist?(key) - instrument :exist, key: key do |payload| - answer = ActiveStorage::Postgresql::File.where(key: key).exists? + instrument :exist, key: do |payload| + answer = ActiveStorage::Postgresql::File.where(key:).exists? payload[:exist] = answer answer end @@ -60,11 +60,11 @@ def delete_prefixed(prefix) end def private_url(key, expires_in:, filename:, content_type:, disposition:, **) - generate_url(key, expires_in: expires_in, filename: filename, content_type: content_type, disposition: disposition) + generate_url(key, expires_in:, filename:, content_type:, disposition:) end def public_url(key, filename:, content_type: nil, disposition: :attachment, **) - generate_url(key, expires_in: nil, filename: filename, content_type: content_type, disposition: disposition) + generate_url(key, expires_in: nil, filename:, content_type:, disposition:) end def url(key, **options) @@ -90,23 +90,23 @@ def generate_url(key, expires_in:, filename:, disposition:, content_type:) counter = counter.to_i # End hack - instrument :url, key: key do |payload| - content_disposition = content_disposition_with(type: disposition, filename: filename) + instrument :url, key: do |payload| + content_disposition = content_disposition_with(type: disposition, filename:) verified_key_with_expiration = ActiveStorage.verifier.generate( { - key: key, + key:, disposition: content_disposition, - content_type: content_type + content_type: }, - expires_in: expires_in, + expires_in:, purpose: :blob_key ) generated_url = url_helpers.rails_postgresql_service_url(verified_key_with_expiration, **url_options, disposition: content_disposition, - content_type: content_type, - filename: filename, + content_type:, + filename:, retry_count: counter ) payload[:url] = generated_url @@ -116,15 +116,15 @@ def generate_url(key, expires_in:, filename:, disposition:, content_type:) end def url_for_direct_upload(key, expires_in:, content_type:, content_length:, checksum:, custom_metadata: {}) - instrument :url, key: key do |payload| + instrument :url, key: do |payload| verified_token_with_expiration = ActiveStorage.verifier.generate( { - key: key, - content_type: content_type, + key:, + content_type:, content_length: content_length, - checksum: checksum + checksum: }, - expires_in: expires_in, + expires_in:, purpose: :blob_token ) diff --git a/test/controllers/password_credentials_controller_test.rb b/test/controllers/password_credentials_controller_test.rb index c33e5cf0c..8e79d5e5b 100644 --- a/test/controllers/password_credentials_controller_test.rb +++ b/test/controllers/password_credentials_controller_test.rb @@ -19,7 +19,7 @@ class PasswordCredentialsControllerTest < ActionDispatch::IntegrationTest test "should get edit" do token = get_test_user_token(@user) - get edit_password_credential_url, params: { token: token } + get edit_password_credential_url, params: { token: } assert_response :success assert assigns(:user).is_a?(User) @@ -37,7 +37,7 @@ class PasswordCredentialsControllerTest < ActionDispatch::IntegrationTest token = get_test_user_token(@user) @user.destroy # make sure the user doesn't exist when we try to find it - get edit_password_credential_url, params: { token: token } + get edit_password_credential_url, params: { token: } assert_response :not_found end @@ -46,7 +46,7 @@ class PasswordCredentialsControllerTest < ActionDispatch::IntegrationTest token = get_test_user_token(@user) new_password = "new_password" - patch password_credential_url, params: { token: token, password: new_password } + patch password_credential_url, params: { token:, password: new_password } assert_response :redirect assert_redirected_to root_path @@ -61,7 +61,7 @@ class PasswordCredentialsControllerTest < ActionDispatch::IntegrationTest token = get_test_user_token(@user) new_password = "new_password" - patch password_credential_url, params: { token: token, password: new_password } + patch password_credential_url, params: { token:, password: new_password } assert_response :redirect assert_redirected_to root_path diff --git a/test/models/message_test.rb b/test/models/message_test.rb index fd27ed03f..cc240dbbc 100644 --- a/test/models/message_test.rb +++ b/test/models/message_test.rb @@ -123,7 +123,7 @@ class MessageTest < ActiveSupport::TestCase assert_raises ActiveRecord::RecordInvalid do Message.create!( - assistant: assistant, + assistant:, conversation: conversation_owned_by_someone_else, content_text: "This should fail" ) @@ -137,8 +137,8 @@ class MessageTest < ActiveSupport::TestCase assert_nothing_raised do message = Message.create!( - assistant: assistant, - conversation: conversation, + assistant:, + conversation:, content_text: "This works since Conversation is owned by Current.user" ) assert_equal Current.user, message.conversation.user @@ -154,8 +154,8 @@ class MessageTest < ActiveSupport::TestCase assert_nothing_raised do message = Message.create!( - assistant: assistant, - conversation: conversation, + assistant:, + conversation:, content_text: "This works since Current.user not set" ) end diff --git a/test/services/toolbox/google_tasks_test.rb b/test/services/toolbox/google_tasks_test.rb index e2b82b931..f2f32bc2f 100644 --- a/test/services/toolbox/google_tasks_test.rb +++ b/test/services/toolbox/google_tasks_test.rb @@ -389,13 +389,13 @@ def lists_data def task_data(title: "Title of task", notes: "notes for task", deleted: false, due: nil, completed: false) { id: "mockid", - title: title, + title:, selfLink: "https://www.googleapis.com/tasks/v1/lists/SjBhVUFfLWtEVElJRnJ2Yg/tasks/NHhjQUY3bGlHVHdPUEwwaA", - notes: notes, + notes:, status: completed ? "completed" : "needsAction", completed: completed.presence && Time.zone.today.strftime("%Y-%m-%dT00:00:00.000Z"), due: due == "clear" ? nil : due, - deleted: deleted, + deleted:, links: [], webViewLink: "https://tasks.google.com/task/4xcAF7liGTwOPL0h" } @@ -403,7 +403,7 @@ def task_data(title: "Title of task", notes: "notes for task", deleted: false, d def tasks_data(deleted: false) { items: [ - task_data(deleted: deleted).merge(position: "00001"), + task_data(deleted:).merge(position: "00001"), { id: "mockid2", position: "00002", @@ -411,7 +411,7 @@ def tasks_data(deleted: false) selfLink: "https://www.googleapis.com/tasks/v1/lists/SjBhVUFfLWtEVElJRnJ2Yg/tasks/NHhjQUY3bGlHVHdPUEwwaA", status: "needsAction", due: nil, - deleted: deleted, + deleted:, links: [], webViewLink: "https://tasks.google.com/task/4xcAF7liGTwOPL0h" },{ @@ -421,7 +421,7 @@ def tasks_data(deleted: false) selfLink: "https://www.googleapis.com/tasks/v1/lists/SjBhVUFfLWtEVElJRnJ2Yg/tasks/NHhjQUY3bGlHVHdPUEwwaA", status: "needsAction", due: nil, - deleted: deleted, + deleted:, links: [], webViewLink: "https://tasks.google.com/task/4xcAF7liGTwOPL0h" }] @@ -432,13 +432,13 @@ def create_data(title:, notes: nil, due: nil) { kind: "tasks#task", id: "mockid", etag: "\"NzU5Mjc2NTA2\"", - title: title, + title:, updated: "2024-06-18T21:29:54.000Z", selfLink: "https://www.googleapis.com/tasks/v1/lists/SjBhVUFfLWtEVElJRnJ2Yg/tasks/NHhjQUY3bGlHVHdPUEwwaA", position: "00000000000000000000", - notes: notes, + notes:, status: "needsAction", - due: due, + due:, links: [], webViewLink: "https://tasks.google.com/task/4xcAF7liGTwOPL0h" }.compact diff --git a/test/support/sdk_helper.rb b/test/support/sdk_helper.rb index ad6cdd7b1..fec305809 100644 --- a/test/support/sdk_helper.rb +++ b/test/support/sdk_helper.rb @@ -20,24 +20,24 @@ def stub_response(verb, method, status:, response: {}, &block) end def stub_get_response(method, status:, response: {}, &block) - stub_response(:get, method, status: status, response: response, &block) + stub_response(:get, method, status:, response:, &block) end def stub_post_response(method, status:, response: {}, &block) - stub_response(:post, method, status: status, response: response, &block) + stub_response(:post, method, status:, response:, &block) end def stub_patch_response(method, status:, response: {}, &block) - stub_response(:patch, method, status: status, response: response, &block) + stub_response(:patch, method, status:, response:, &block) end def stub_delete_response(method, status:, response: {}, &block) - stub_response(:delete, method, status: status, response: response, &block) + stub_response(:delete, method, status:, response:, &block) end def response_for(status, hash) OpenData.new( - status: status, + status:, body: hash.to_json, ) end