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

Use max instead of sort.last in update check #1442

Merged
merged 1 commit into from
May 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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