thoughtbot / testing-rails

Source code for the Testing Rails book
Other
279 stars 48 forks source link

Deleting validate_uniquess_of(:url) in validations_and_associations.md ? #99

Open ryanzidago opened 5 years ago

ryanzidago commented 5 years ago

Wouldn't it be clearer to get rid of the following line of code:

it { is_expected.to validate_uniqueness_of(:url) }

in validations_and_associations.md, since urls are not expected to be unique (see link_spec.rb)?

I went on to add the corresponding code for validating the uniqueness of urls before realizing the urls do not need to be unique and uniqueness of urls are not implemented in the example_app.

banister commented 5 years ago

Unsubscribe

On Sun, Jul 21, 2019, 11:09 AM Ryan Zidago notifications@github.com wrote:

Wouldn't it be clearer to get rid of the following line of code:

it { is_expected.to validate_presence_of(:url) }

in validations_and_associations.md https://github.com/thoughtbot/testing-rails/blob/master/book/types_of_tests/model_specs/validations_and_associations.md since urls are not expected to be unique (see link_spec.rb https://github.com/thoughtbot/testing-rails/blob/master/example_app/spec/models/link_spec.rb )?

I went on to add the corresponding code for validating the uniqueness of urls before realizing the urls do not need to be unique and uniqueness of urls are not implemented in the example_app.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/thoughtbot/testing-rails/issues/99?email_source=notifications&email_token=AAAEI3T343LKQ6ELLKSENA3QAQRTFA5CNFSM4IFRRTV2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HAPHJEA, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAEI3QM4EDXUKVWEWV4WMTQAQRTFANCNFSM4IFRRTVQ .

psantos10 commented 5 years ago

@ryanzidago if this line is removed, a blank value (empty , " ") will be accepted if is unique.

olavfosse commented 4 years ago

@ryanzidago if this line is removed, a blank value (empty , " ") will be accepted if is unique.

How come? The presence: true prevents nils and empty strings from being accepted.