testing-rails icon indicating copy to clipboard operation
testing-rails copied to clipboard

Deleting validate_uniquess_of(:url) in validations_and_associations.md ?

Open ryanzidago opened this issue 6 years ago • 3 comments

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.

ryanzidago avatar Jul 21 '19 09:07 ryanzidago

Unsubscribe

On Sun, Jul 21, 2019, 11:09 AM Ryan Zidago [email protected] 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 .

banister avatar Jul 21 '19 21:07 banister

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

psantos10 avatar Jul 23 '19 10:07 psantos10

@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.

olavfosse avatar Feb 19 '20 16:02 olavfosse