Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ group :development do
gem "haml_lint", require: false
gem "letter_opener"
gem "rack-mini-profiler", "~> 4.0"
gem "rubocop", "1.84.1", require: false
gem "rubocop", "1.85.1", require: false
gem "rubocop-performance"
gem "rubocop-rails"
gem "rubocop-rspec"
Expand Down
10 changes: 8 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ GEM
jsbundling-rails (1.3.1)
railties (>= 6.0.0)
json (2.18.1)
json-schema (6.1.0)
addressable (~> 2.8)
bigdecimal (>= 3.1, < 5)
jwt (3.1.2)
base64
kgio (2.11.4)
Expand Down Expand Up @@ -420,6 +423,8 @@ GEM
zeitwerk
marcel (1.0.4)
matrix (0.4.3)
mcp (0.8.0)
json-schema (>= 4.1)
method_source (1.1.0)
mime-types (3.7.0)
logger
Expand Down Expand Up @@ -607,10 +612,11 @@ GEM
rspec-support (3.13.6)
rspec_junit_formatter (0.6.0)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (1.84.1)
rubocop (1.85.1)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
mcp (~> 0.6)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
Expand Down Expand Up @@ -831,7 +837,7 @@ DEPENDENCIES
rspec-collection_matchers
rspec-rails
rspec_junit_formatter
rubocop (= 1.84.1)
rubocop (= 1.85.1)
rubocop-performance
rubocop-rails
rubocop-rspec
Expand Down
3 changes: 3 additions & 0 deletions app/lib/nucore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ class NotPermittedWhileActingAs < NUCore::Error

class PurchaseException < NUCore::Error; end

class OrderDetailUpdateException < NUCore::Error
end

end
2 changes: 1 addition & 1 deletion app/models/email_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def self.notify(user, keys, wait: 24.hours)
end

def self.key_for(keys)
Array(keys).map(&:to_s).join("/")
Array(keys).join("/")
end

end
2 changes: 1 addition & 1 deletion app/models/product_display_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def to_s
name
end

Fake = Struct.new(:name, :products, keyword_init: true) do
Fake = Struct.new(:name, :products) do
def to_s
name
end
Expand Down
7 changes: 0 additions & 7 deletions app/services/order_detail_updater.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# frozen_string_literal: true

module NUCore

class OrderDetailUpdateException < StandardError
end

end

class OrderDetailUpdater

attr_reader :order, :params, :quantities_changed
Expand Down
2 changes: 1 addition & 1 deletion app/services/order_row_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def order_key
def row_with_errors
# Start with a hash of HEADERS keys with nil values to ensure optional columns
# are included in the report even if they are not in the uploaded CSV.
new_row = HEADERS.each_with_object({}) { |header, hash| hash[header] = nil }
new_row = HEADERS.to_h { |header| [header, nil] }
new_row.merge!(@row)
new_row[header(:errors)] = errors.join(", ")

Expand Down
4 changes: 2 additions & 2 deletions app/services/projects_search/searcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def options
end

def to_options_by_searcher
@to_h ||= options.each_with_object({}) do |searcher, hash|
hash[searcher.key] = searcher.options
@to_h ||= options.to_h do |searcher|
[searcher.key, searcher.options]
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/services/research_safety_certification_lookup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def missing_from(certificates)
end

def certificates_with_status
ResearchSafetyCertificate.ordered.each_with_object({}) do |certificate, hash|
hash[certificate] = adapter.certified?(certificate)
ResearchSafetyCertificate.ordered.to_h do |certificate|
[certificate, adapter.certified?(certificate)]
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/services/transaction_search/searcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ def options
end

def to_options_by_searcher
@to_h ||= options.each_with_object({}) do |searcher, hash|
hash[searcher.key] = searcher.options
@to_h ||= options.to_h do |searcher|
[searcher.key, searcher.options]
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# frozen_string_literal: true

class DurationRate < ApplicationRecord; end

class UpdateDurationRateRateForInternalPriceGroups < ActiveRecord::Migration[7.0]
class DurationRate < ApplicationRecord; end

def up
DurationRate.all.each(&:set_rate_from_base)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

class Product < ApplicationRecord; end

class UpdateCrossCoreOrderingAvailableInProducts < ActiveRecord::Migration[7.0]
class Product < ApplicationRecord; end

def up
change_column :products, :cross_core_ordering_available, :boolean, default: false, null: false

Expand Down
22 changes: 13 additions & 9 deletions lib/tasks/order_details.rake
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ namespace :order_details do
task :uncancel, [:filename] => :environment do |_t, args|
Rails.logger = Logger.new(STDOUT)
uncanceler = OrderUncanceler.new
File.open(args[:filename]).each_line do |line|
order_detail = OrderDetail.find_by(id: line.chomp)
if order_detail
uncanceler.uncancel_to_complete(order_detail)
else
puts "Could not find order detail #{line}"
File.open(args[:filename]) do |file|
file.each_line do |line|
order_detail = OrderDetail.find_by(id: line.chomp)
if order_detail
uncanceler.uncancel_to_complete(order_detail)
else
puts "Could not find order detail #{line}"
end
end
end
end
Expand Down Expand Up @@ -122,10 +124,12 @@ namespace :order_details do

def self.remove_orders(file)
OrderDetail.transaction do
File.open(file, "r").each_line do |line|
next unless /([0-9]+)-([0-9]+)/ =~ line
File.open(file, "r") do |file|
file.each_line do |line|
next unless /([0-9]+)-([0-9]+)/ =~ line

remove_order(OrderDetail.find(Regexp.last_match(2)))
remove_order(OrderDetail.find(Regexp.last_match(2)))
end
end
end
puts "Done"
Expand Down
28 changes: 14 additions & 14 deletions spec/app_support/reservations/date_support_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@
["2015-01-01T01:00:59", 60],
]
.each do |timestring, expected_minutes|
context "and the actual_end_at is #{timestring}" do
let(:actual_end_at) { Time.zone.parse(timestring) }
context "and the actual_end_at is #{timestring}" do
let(:actual_end_at) { Time.zone.parse(timestring) }

it "returns #{expected_minutes}" do
expect(reservation.actual_duration_mins).to eq(expected_minutes)
end
it "returns #{expected_minutes}" do
expect(reservation.actual_duration_mins).to eq(expected_minutes)
end
end
end

context "and actual_end_at is unset" do
Expand All @@ -97,11 +97,11 @@
["2015-01-01T01:00:59", 60],
]
.each do |timestring, expected_minutes|
context "and the base_time is #{timestring}" do
it "returns #{expected_minutes}" do
expect(reservation.actual_duration_mins).to be_blank
end
context "and the base_time is #{timestring}" do
it "returns #{expected_minutes}" do
expect(reservation.actual_duration_mins).to be_blank
end
end
end
end
end
Expand Down Expand Up @@ -211,13 +211,13 @@
["2015-01-01T01:00:59", 60],
]
.each do |timestring, expected_minutes|
context "and reserve_end_at is #{timestring}" do
let(:reserve_end_at) { Time.zone.parse(timestring) }
context "and reserve_end_at is #{timestring}" do
let(:reserve_end_at) { Time.zone.parse(timestring) }

it "returns #{expected_minutes}" do
expect(reservation.duration_mins).to eq(expected_minutes)
end
it "returns #{expected_minutes}" do
expect(reservation.duration_mins).to eq(expected_minutes)
end
end
end

context "and reserve_end_at is unset" do
Expand Down
4 changes: 2 additions & 2 deletions spec/services/order_details/reconciler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
OrderDetail.create!(product: product, quantity: 1, actual_cost: 1, actual_subsidy: 0, state: "complete", statement:, order_id: order.id, created_by_user: user)
end
end
let(:params) { order_details.each_with_object({}) { |od, h| h[od.id.to_s] = ActionController::Parameters.new(selected: "1", reconciled: "1") } }
let(:params) { order_details.to_h { |od| [od.id.to_s, ActionController::Parameters.new(selected: "1", reconciled: "1")] } }
let(:reconciler) { described_class.new(OrderDetail.all, params, Time.current, "reconciled") }
let(:account) { create(:account, :with_account_owner, type: Account.config.statement_account_types.first) }
let(:statement) { create(:statement, facility: product.facility, account:, created_by_user: user) }
Expand Down Expand Up @@ -71,7 +71,7 @@
context "with NO bulk note" do
context "with reconciled note set" do
let(:reconciler) { described_class.new(OrderDetail.all, params, Time.current, "reconciled") }
let(:params) { order_details.each_with_object({}) { |od, h| h[od.id.to_s] = ActionController::Parameters.new(selected: "1", reconciled: "1", reconciled_note: "note #{od.id}") } }
let(:params) { order_details.to_h { |od| [od.id.to_s, ActionController::Parameters.new(selected: "1", reconciled: "1", reconciled_note: "note #{od.id}")] } }

it "adds the note to the appropriate order details" do
reconciler.reconcile_all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ def datepicker_field_input(form, key)
end

def user_types
RecipientSearcher.user_types.each_with_object({}) do |user_type, hash|
hash[user_type] = I18n.t("bulk_email.user_type.#{user_type}")
RecipientSearcher.user_types.to_h do |user_type|
[user_type, I18n.t("bulk_email.user_type.#{user_type}")]
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def initialize(saml_response)
end

def to_h
@saml_response.attributes.resource_keys.each_with_object({}) do |key, memo|
memo[key] = @saml_response.attribute_value_by_resource_key(key)
@saml_response.attributes.resource_keys.to_h do |key|
[key, @saml_response.attribute_value_by_resource_key(key)]
end.with_indifferent_access
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ module ParamUpdaterExtension
included do
permitted_attributes.append(
occupancy_attributes: [
entry_at: [:date, :hour, :minute, :ampm],
exit_at: [:date, :hour, :minute, :ampm],
{
entry_at: [:date, :hour, :minute, :ampm],
exit_at: [:date, :hour, :minute, :ampm]
},
],
)
end
Expand Down
Loading