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
#3044: Use find_by
instead of find_by_xxx
#3925
#3044: Use find_by
instead of find_by_xxx
#3925
Conversation
@@ -250,7 +250,7 @@ def config(options = {}) | |||
let(:different_post) { double } | |||
before do | |||
allow(Post).to receive(:primary_key).and_return 'something_else' | |||
allow(Post).to receive(:find_by_something_else).with('55555') { different_post } | |||
allow(Post).to receive(:find_by).with('something_else' => '55555') { different_post } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [95/80]
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
public_send
find_by
instead of find_by_xxx
allow(Post).to receive(:find_by). | ||
with("something_else" => "55555") { different_post } | ||
else | ||
allow(Post).to receive(:find_by_something_else).with('55555') { different_post } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [92/80]
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Ok, ready for review. |
👍 looks good, but the commits are a bit confusing. Would you mind squashing them together? |
@@ -232,7 +232,11 @@ def config(options = {}) | |||
let(:resource) { namespace.register(Post) } | |||
let(:post) { double } | |||
before do | |||
allow(Post).to receive(:find_by_id).with('12345') { post } | |||
if Rails::VERSION::MAJOR > 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's more clear if you write >= 4
4fdc0cb
to
23d47d2
Compare
Please squash the last commits too |
23d47d2
to
986b7d0
Compare
Updated, sorry for delay, I had a vacation... |
#3044: Use `find_by` instead of `find_by_xxx`
By #3044 , #3090 and according to http://guides.rubyonrails.org/4_2_release_notes.html#adequate-record
Also, should help to prevent: