Skip to content

Commit

Permalink
Merge pull request #1601 from zendesk/grosser/24
Browse files Browse the repository at this point in the history
SAMSON-322 use ruby 2.4
  • Loading branch information
grosser authored Aug 23, 2017
2 parents 1049803 + 78ed666 commit da57dcb
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.3
2.4.1
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ before_script:
- mysql -u root -e 'set GLOBAL innodb_large_prefix = true'
- mysql -u root -e 'set GLOBAL innodb_file_per_table = true'
- mysql -u root -e 'set GLOBAL innodb_file_format = "barracuda"'
- mysql -u root -e 'GRANT ALL ON *.* TO 'travis'@'localhost';'

2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ DEPENDENCIES
webmock

RUBY VERSION
ruby 2.3.3p222
ruby 2.4.1p111

BUNDLED WITH
1.15.3
2 changes: 1 addition & 1 deletion app/models/concerns/attr_encrypted_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'attr_encrypted'

module AttrEncryptedSupport
ENCRYPTION_KEY = Rails.application.secrets.secret_key_base
ENCRYPTION_KEY = Rails.application.secrets.secret_key_base[0...32]
ENCRYPTION_KEY_SHA = Digest::SHA2.hexdigest(Rails.application.secrets.secret_key_base)

def self.included(base)
Expand Down
9 changes: 6 additions & 3 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ class User < ActiveRecord::Base
before_soft_delete :destroy_user_project_roles

scope :search, ->(query) {
return self if query.blank?
query = ActiveRecord::Base.send(:sanitize_sql_like, query)
where("name LIKE ? OR email LIKE ?", "%#{query}%", "%#{query}%")
if query.blank?
self
else
query = ActiveRecord::Base.send(:sanitize_sql_like, query)
where("name LIKE ? OR email LIKE ?", "%#{query}%", "%#{query}%")
end
}

def self.with_role(role_id, project_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@

it "shows nothing when flowdock fails to fetch users" do
stub_request(:get, "https://api.flowdock.com/v1/users").to_timeout
Rails.logger.expects(:error).with(
'Error fetching flowdock users (token invalid / flowdock down). Net::OpenTimeout: execution expired'
)
Rails.logger.expects(:error).with(includes('Error fetching flowdock users'))
service.users.must_equal([])

# is cached
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
it "returns empty users when there's an error" do
stub_request(:post, "https://slack.com/api/users.list").
to_return(body: {ok: false, error: "some error"}.to_json)
Rails.logger.expects(:error).with('Error fetching slack users: some error')
Rails.logger.expects(:error).with(includes('Error fetching slack users'))
service.users.must_equal([])

# is cached
Expand All @@ -35,9 +35,7 @@

it "shows nothing when slack fails to fetch users" do
stub_request(:post, "https://slack.com/api/users.list").to_timeout
Rails.logger.expects(:error).with(
'Error fetching slack users (token invalid / service down). Faraday::ConnectionFailed: execution expired'
)
Rails.logger.expects(:error).with(includes('Error fetching slack users'))
service.users.must_equal([])

# is cached
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/application_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@
end

it "fails on unknown" do
assert_raises(ArgumentError) { link_to_resource(123) }.message.must_equal "Unsupported resource Fixnum"
assert_raises(ArgumentError) { link_to_resource(123) }.message.must_equal "Unsupported resource Integer"
end

# sanity check that we did not miss anything especially plugin models
Expand Down
9 changes: 7 additions & 2 deletions test/models/docker_builder_service_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ def stub_push(repo, tag, result, force: false)
DockerBuilderService.class_variable_set(:@@docker_major_version, nil)
end

it "adds login commands" do
it "uses email flag when docker is old" do
DockerBuilderService.expects(:read_docker_version).returns("1.12.0")
called[1].must_equal "docker login --username fo\\+o --password ba\\+r --email [email protected] ba\\+z.com"
end

Expand All @@ -391,9 +392,13 @@ def stub_push(repo, tag, result, force: false)
end

it "does not use email flag on newer docker versions" do
DockerBuilderService.expects(:docker_major_version).returns(17)
DockerBuilderService.expects(:read_docker_version).returns("17.0.0")
called[1].must_equal "docker login --username fo\\+o --password ba\\+r ba\\+z.com"
end

it "can do a real docker check" do
called # checking that it does not blow up ... result varies depending on if docker is installed
end
end

it "copies previous config files from ENV location" do
Expand Down

0 comments on commit da57dcb

Please sign in to comment.