Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[26829] Patch reform-rails to use activerecord i18n_scope #6105

Merged
merged 1 commit into from
Jan 9, 2018
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
10 changes: 10 additions & 0 deletions config/initializers/reform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@
include Reform::Form::ActiveModel::Validations
end

Reform::Form::ActiveModel::Validations::Validator.class_eval do
##
# use activerecord as the base scope instead of 'activemodel' to be compatible
# to the messages we have already stored
def self.i18n_scope
:activerecord
end
end


require 'reform/contract'

require 'open_project/patches/reform'
Expand Down
12 changes: 12 additions & 0 deletions spec/contracts/work_packages/base_contract_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,18 @@
describe 'due date' do
it_behaves_like 'a parent unwritable property', :due_date
it_behaves_like 'a date attribute', :due_date

it 'returns an error when trying to set it before the start date' do
work_package.start_date = Date.today + 2.days
work_package.due_date = Date.today

contract.validate

message = I18n.t('activerecord.errors.messages.greater_than_or_equal_to_start_date')

expect(contract.errors[:due_date])
.to include message
end
end

describe 'percentage done' do
Expand Down