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

Refactor AR's validations_test.rb #10662

Merged
merged 1 commit into from
May 11, 2014
Merged

Refactor AR's validations_test.rb #10662

merged 1 commit into from
May 11, 2014

Conversation

take
Copy link
Contributor

@take take commented May 17, 2013

Some refactoring, tell me anything if u thought something about this PR :D

@@ -14,28 +14,30 @@ class ValidationsTest < ActiveRecord::TestCase
# Other classes we mess with will be dealt with in the specific tests
repair_validations(Topic)

def test_error_on_create
def test_valid_question_uses_create_context_when_new_data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not super-fond of this: took me a bit to parse what valid_question meant here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm i c, what would u prefer than ? :D

@take
Copy link
Contributor Author

take commented Jun 19, 2013

@al2o3cr what do u think about this now? :D

assert r.save, "First save should be successful"

assert r.valid?, "First validation should be successful"
r.save

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just this change is not necessary, it'll run validations twice, you can use r.save in the assert call.

@carlosantoniodasilva
Copy link
Member

Changes look fine, added minor comments and please squash. Thanks.

@take
Copy link
Contributor Author

take commented Jun 26, 2013

@carlosantoniodasilva thx! udpated and squashed and pushed 😄

r = WrongReply.new
r.title = "Wrong Create"
assert !r.save
assert !r.valid?
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not assert_not r.valid??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not 😃 thx

@take
Copy link
Contributor Author

take commented Jul 29, 2013

fixed and rebased master and force pushed 😃

the failing build is due to some connection problem

The `:context` switch feature is implemented in
ActiveRecord::Validations#valid? method, so we should rename the test
names, and execute `valid?` in the test.

Change test name in AR's validations_test.rb

This test is testing save method's code
carlosantoniodasilva added a commit that referenced this pull request May 11, 2014
…--Validations#valid-

Refactor AR's validations_test.rb
@carlosantoniodasilva carlosantoniodasilva merged commit d4fafeb into rails:master May 11, 2014
@take take deleted the change-test-name-for-ActiveRecord--Validations#valid- branch May 12, 2014 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants