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 lib/active_resource/validations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def load_remote_errors(remote_errors, save_cache = false) # :nodoc:
# my_person.valid?
# # => false
#
def valid?
def valid?(context = nil)
run_callbacks :validate do
super
load_remote_errors(@remote_errors, true) if defined?(@remote_errors) && @remote_errors.present?
Expand Down
12 changes: 12 additions & 0 deletions test/cases/validations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ def test_client_side_validation_maximum
assert_equal ["is too long (maximum is 10 characters)"], project.errors[:description]
end

def test_invalid_method
p = new_project

assert_not p.invalid?
end

def test_validate_bang_method
p = new_project(name: nil)

assert_raise(ActiveModel::ValidationError) { p.validate! }
end

protected
# quickie helper to create a new project with all the required
# attributes.
Expand Down