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

#3044: Use find_by instead of find_by_xxx #3925

Merged
merged 1 commit into from May 19, 2015

Conversation

avokhmin
Copy link
Contributor

@avokhmin avokhmin commented May 1, 2015

By #3044 , #3090 and according to http://guides.rubyonrails.org/4_2_release_notes.html#adequate-record

Also, should help to prevent:

NoMethodError - private method `find_by_id' called for #<Class:0x00000110288708>:
  activeadmin (1.0.0.pre1) lib/active_admin/resource.rb:147:in `find_resource'

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

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.

@avokhmin avokhmin changed the title #3044: Use public_send #3044: Use find_by instead of find_by_xxx May 1, 2015
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 }

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.

@avokhmin
Copy link
Contributor Author

avokhmin commented May 1, 2015

Ok, ready for review.

@seanlinsley
Copy link
Contributor

👍 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
Copy link
Member

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

@timoschilling
Copy link
Member

Please squash the last commits too

@avokhmin
Copy link
Contributor Author

Updated, sorry for delay, I had a vacation...

timoschilling added a commit that referenced this pull request May 19, 2015
#3044: Use `find_by` instead of `find_by_xxx`
@timoschilling timoschilling merged commit cef68b7 into activeadmin:master May 19, 2015
@avokhmin avokhmin deleted the 3044-use-public_send-2 branch May 19, 2015 14:11
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