Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Rails 4.2.8? #900

Merged
merged 3 commits into from Mar 13, 2017
Merged

Rails 4.2.8? #900

merged 3 commits into from Mar 13, 2017

Conversation

vincemtnz
Copy link
Contributor

@vincemtnz vincemtnz commented Mar 1, 2017

Because why not.

Rails 4.2.8 also brings ruby 2.4 support so we can either keep 2.3.3 or update to 2.4.0. In this PR I've taken the 2.4.0 route (was that predictable?) but I'll describe both options:

Staying with ruby 2.3.3
Other than updating the rails gem, I don't think any other changes are necessary, but since we're updating the Gemfile / Gemfile.lock tandem, I'd also take the opportunity to change the github: '...' gems to use git: 'https://...' so we can get rid of the annoying bundler warnings - or am I the only one that's bothered?

With ruby 2.4.0
With 2.4 a few changes are necessary:

@vincemtnz vincemtnz force-pushed the rails-4.2.8 branch 3 times, most recently from cd7fda2 to 762bc5b Compare March 1, 2017 21:10
customer: @customer,
store_in_vault: @store_in_vault
).create.id
end
Copy link
Member

@osahyoun osahyoun Mar 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rubocop, you naughty machine.

@osahyoun
Copy link
Member

osahyoun commented Mar 2, 2017

Vince, thank you for doing this. I love it.

@osahyoun
Copy link
Member

osahyoun commented Mar 2, 2017

oh, and I'm totally down with 2.4.0

@osahyoun
Copy link
Member

osahyoun commented Mar 3, 2017

Vince, I think we should get this merged. What say you?

@@ -38,7 +38,7 @@ def liquid_data(supplemental_data = {})
end

def recurring?
read_attribute(:recurring_default) > 0
read_attribute(:recurring_default).positive?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this rubocop?

@@ -26,7 +26,7 @@ class Link < ActiveRecord::Base
private

def url_has_protocol
unless %r{^(https?:)?\/\/}i =~ url
unless %r{^(https?:)?\/\/}i.match?(url)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this rubocop?

@@ -33,7 +33,7 @@ def dup
clone = super
clone.save!

clone.form.form_elements = form.form_elements.map(&:dup) if clone.form
clone.form&.form_elements = form.form_elements.map(&:dup)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are not equivalent expressions. If clone.form is not present this raises an Undefined method form elements for nil exception. We should keep the guard expression.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

Copy link
Contributor Author

@vincemtnz vincemtnz Mar 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it though? I'll write a test case to double check, but this seems to work:

irb(main):014:0> house = OpenStruct.new(room: OpenStruct.new(people: 0))
=> #<OpenStruct room=#<OpenStruct people=0>>
irb(main):019:0> house.room.people = 10
=> 10
irb(main):021:0> house.cupboards&.people = 10
=> nil
irb(main):020:0> house.cupboards.people = 10
NoMethodError: undefined method `people=' for nil:NilClass
	from (irb):20
	from /Users/vincent/.rbenv/versions/2.3.3/bin/irb:11:in `<main>'

Copy link
Contributor

@rodrei rodrei Mar 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's interesting! I didn't know you could use the safe operator on the left side of an assignment. This means that it's clearly doing more than the old ActiveSupport try.

@@ -17,9 +17,9 @@ class Share::Email < ActiveRecord::Base
include Share::Variant

validates :subject, :body, presence: true
validate :has_link
validate :has_link, unless: -> { body.nil? }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it safe to remove this? This change makes the validation run even when the body is nil.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rodrei it's an addition.

@@ -17,9 +17,9 @@ class Share::Twitter < ActiveRecord::Base
include Share::Variant

validates :description, presence: true
validate :has_link
validate :has_link, unless: -> { description.nil? }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

page: @page,
url: @page_url
)
end
Copy link
Contributor

@rodrei rodrei Mar 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate this indentation style 👎 . I vote for us to remove this rubocop check and align it like this:

variant = if condition?
  do.something
else
  do.something_else
end

@@ -7,7 +7,7 @@ def initialize(params)

def search
[*@queries].each do |search_type, query|
if !validate_query(query)
if query.blank?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

@@ -6,7 +6,7 @@ module Helper
def check_petition_name_is_available(name)
resp = ActionKit::Client.get('petitionpage', params: { _limit: 1, name: name })
if resp.code == 200
JSON.parse(resp.body)['meta']['total_count'] == 0
(JSON.parse(resp.body)['meta']['total_count']).zero?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this rubocop?

@rodrei
Copy link
Contributor

rodrei commented Mar 3, 2017

Other than my comments, this looks awesome! Great job @eyko!

@osahyoun
Copy link
Member

osahyoun commented Mar 7, 2017

@eyko sending you a friendly ping.

@osahyoun
Copy link
Member

This seemed to work fine on staging. Let's try and get it merged before Wednesday - does that sound feasible?

@vincemtnz vincemtnz merged commit a037ddf into development Mar 13, 2017
@osahyoun osahyoun deleted the rails-4.2.8 branch March 22, 2018 18:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants