Skip to content
Open
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
3 changes: 0 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ gem 'mini_magick'
gem 'mission_control-jobs'
gem 'mutex_m', '0.1.1'
gem 'neighbor'
gem 'net-imap', require: false
gem 'net-pop', require: false
gem 'net-smtp', require: false # TODO: Remove it if you use rails 7.0.1
gem 'newspaper'
gem 'oauth2'
gem 'omniauth', '~> 2.1.1'
Expand Down
22 changes: 7 additions & 15 deletions app/models/campaign.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ class Campaign < ApplicationRecord
validates :start_at, presence: true
validates :end_at, presence: true

# TODO: Rails 7に更新後、 `ComparisonValidator` を使うように直す。
# refs: https://github.com/rails/rails/pull/40095
# validates :end_at, greater_than: :start_at
with_options if: -> { start_at && end_at && trial_period } do
validate :start_at_cannot_be_greater_than_end_at
end

validates :end_at, comparison: {
greater_than: :start_at,
message: lambda { |object, _data|
I18n.t('activerecord.errors.models.campaign.attributes.end_at.greater_than_start_at',
shortest_end_at: I18n.l(object.start_at, format: :short))
}
}
validates :title, presence: true
validates :trial_period, presence: true, numericality: { greater_than_or_equal_to: 4 }

Expand Down Expand Up @@ -56,12 +56,4 @@ def user_trial_period(join_date)
end
end
end

private

def start_at_cannot_be_greater_than_end_at
return if end_at > start_at

errors.add(:end_at, :format, shortest_end_at: I18n.l(start_at, format: :short))
end
end
2 changes: 1 addition & 1 deletion config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ ja:
campaign:
attributes:
end_at:
format: 'は%{shortest_end_at}以降を入力してください。'
greater_than_start_at: 'は%{shortest_end_at}以降を入力してください。'
doorkeeper/application:
attributes:
redirect_uri:
Expand Down
1 change: 0 additions & 1 deletion test/system/attachments_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

# Pull Request #4182(https://github.com/fjordllc/bootcamp/pull/4182) で Rails 7 への移行完了後に削除する
require 'application_system_test_case'

class AttachmentsTest < ApplicationSystemTestCase
Expand Down
Loading