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

Fix SystemStackError with ActiveRecord #27

Merged
merged 1 commit into from May 12, 2016

Conversation

@garethrees
Copy link
Contributor

garethrees commented Oct 8, 2015

Fixes #26

If you use the default otp_counter column name, InstanceMethodsOnActivation#otp_counter calls otp_counter resulting in a stack overflow.

ActiveRecord::Schema.define do
self.verbose = false

create_table :activerecord_users, :force => true do |t|

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Oct 8, 2015

Use the new Ruby 1.9 hash syntax.

t.string :otp_secret_key
t.timestamps
end

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Oct 8, 2015

Extra empty line detected at block body end.

@@ -13,6 +13,10 @@ def setup
@member = Member.new
@member.email = nil
@member.run_callbacks :create

@ar_user = ActiverecordUser.new
@ar_user.email = 'roberto@heapsource.com'

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Oct 8, 2015

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@@ -34,6 +38,17 @@ def test_counter_based_otp
assert code != @member.otp_code(auto_increment: true)
end

def test_counter_based_otp_active_record

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Oct 8, 2015

Assignment Branch Condition size for test_counter_based_otp_active_record is too high. [17.12/15]

end

def otp_counter=(attr)
self.public_send("#{self.class.otp_counter_column_name}=", attr)
if self.class.otp_counter_column_name != 'otp_counter'

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Oct 8, 2015

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@@ -96,11 +96,19 @@ def otp_column=(attr)
end

def otp_counter
self.public_send(self.class.otp_counter_column_name)
if self.class.otp_counter_column_name != 'otp_counter'

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Oct 8, 2015

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

end

def otp_counter=(attr)
self.public_send("#{self.class.otp_counter_column_name}=", attr)
if self.class.otp_counter_column_name != 'otp_counter'
self.public_send("#{self.class.otp_counter_column_name}=", attr)

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Oct 8, 2015

Redundant self detected.

@@ -96,11 +96,19 @@ def otp_column=(attr)
end

def otp_counter
self.public_send(self.class.otp_counter_column_name)
if self.class.otp_counter_column_name != 'otp_counter'
self.public_send(self.class.otp_counter_column_name)

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Oct 8, 2015

Redundant self detected.

@garethrees garethrees force-pushed the garethrees:stack-too-deep branch 2 times, most recently from a2d02ff to 79a7fed Oct 8, 2015
@garethrees
Copy link
Contributor Author

garethrees commented Oct 8, 2015

Cleared up some Hound warnings – remaining ones are just following existing conventions.

end
rescue => e
warn "#{$0}: #{e}"

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Oct 8, 2015

Trailing whitespace detected.

puts "Writing fake Rakefile"

# Write fake Rakefile for rake since Makefile isn't used
File.open(File.join(File.dirname(__FILE__), 'Rakefile'), 'w') do |f|

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Oct 8, 2015

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@garethrees garethrees force-pushed the garethrees:stack-too-deep branch from 9776b3a to a829c9d Oct 8, 2015
If you use the default `otp_counter` column name,
InstanceMethodsOnActivation#otp_counter calls `otp_counter` resulting in
a stack overflow.
@garethrees garethrees force-pushed the garethrees:stack-too-deep branch from a829c9d to 4592b82 Oct 8, 2015
garethrees referenced this pull request in mysociety/alaveteli Oct 9, 2015
- Adds forked gem for temporary fix; see commit ref for details
- Regenerates the secret and counter when enabled
@garethrees
Copy link
Contributor Author

garethrees commented Oct 26, 2015

Anything I can do to help get this merged? Cheers.

@robertomiranda
Copy link
Member

robertomiranda commented Oct 26, 2015

@garethrees sorry for the delay, I'm going to take a look today

@garethrees
Copy link
Contributor Author

garethrees commented Oct 26, 2015

@robertomiranda thanks, much appreciated! Feel free to get in touch if there's anything you need to clarify :) 🍻

@robertomiranda robertomiranda merged commit c342283 into heapsource:master May 12, 2016
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
hound 4 violations found.
mysociety-pusher pushed a commit to mysociety/alaveteli that referenced this pull request May 17, 2016
@garethrees garethrees deleted the garethrees:stack-too-deep branch May 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.