Skip to content

Commit

Permalink
Merge pull request #1442 from tvdeyen/update-check-fix
Browse files Browse the repository at this point in the history
Use max instead of sort.last in update check
  • Loading branch information
tvdeyen authored May 17, 2018
2 parents d86a655 + 297daa3 commit 9cb7b5a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/alchemy/admin/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def latest_alchemy_version
return '' if versions.blank?
# reject any non release version
versions.reject! { |v| v =~ /[a-z]/ }
versions.sort.last
versions.max
end

# Get alchemy versions from rubygems or github, if rubygems failes.
Expand Down
8 changes: 5 additions & 3 deletions spec/controllers/alchemy/admin/dashboard_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ module Alchemy
end

context "if current Alchemy version is older than latest released version" do
before {
allow(controller).to receive(:latest_alchemy_version).and_return('2.6')
before do
allow_any_instance_of(Net::HTTP).to receive(:request) do
OpenStruct.new({code: '200', body: '[{"number": "2.6"}, {"number": "2.5"}]'})
end
allow(Alchemy).to receive(:version).and_return("2.5")
}
end

it "should render 'true'" do
get :update_check
Expand Down

0 comments on commit 9cb7b5a

Please sign in to comment.