Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

prevent uploading to beta releases older than the current release #1178

Merged
merged 2 commits into from
Aug 15, 2014
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
7 changes: 6 additions & 1 deletion lib/heroku/updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,16 @@ def self.update(prerelease)
extract_zip(zip_filename, download_dir)
FileUtils.rm_f zip_filename

version = client_version_from_path(download_dir)

# do not replace beta version if it is old
return if version < latest_local_version

FileUtils.rm_rf updated_client_path
FileUtils.mkdir_p File.dirname(updated_client_path)
FileUtils.cp_r download_dir, updated_client_path

client_version_from_path(download_dir)
version
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/heroku/client/heroku_postgresql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
end

it "sends an ingress request to the client for production plans" do
attachment.stub :starter_plan? => true
allow(attachment).to receive_messages :starter_plan? => true
host = 'postgres-starter-api.heroku.com'
url = "https://[email protected]:apitoken@#{host}/client/v11/databases/#{attachment.resource_name}/ingress"

Expand Down
78 changes: 39 additions & 39 deletions spec/heroku/updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,57 +13,41 @@ module Heroku

describe('::compare_versions') do
it 'calculates compare_versions' do
subject.compare_versions('1.1.1', '1.1.1').should == 0
expect(subject.compare_versions('1.1.1', '1.1.1')).to eq(0)

subject.compare_versions('2.1.1', '1.1.1').should == 1
subject.compare_versions('1.1.1', '2.1.1').should == -1
expect(subject.compare_versions('2.1.1', '1.1.1')).to eq(1)
expect(subject.compare_versions('1.1.1', '2.1.1')).to eq(-1)

subject.compare_versions('1.2.1', '1.1.1').should == 1
subject.compare_versions('1.1.1', '1.2.1').should == -1
expect(subject.compare_versions('1.2.1', '1.1.1')).to eq(1)
expect(subject.compare_versions('1.1.1', '1.2.1')).to eq(-1)

subject.compare_versions('1.1.2', '1.1.1').should == 1
subject.compare_versions('1.1.1', '1.1.2').should == -1
expect(subject.compare_versions('1.1.2', '1.1.1')).to eq(1)
expect(subject.compare_versions('1.1.1', '1.1.2')).to eq(-1)

subject.compare_versions('2.1.1', '1.2.1').should == 1
subject.compare_versions('1.2.1', '2.1.1').should == -1
expect(subject.compare_versions('2.1.1', '1.2.1')).to eq(1)
expect(subject.compare_versions('1.2.1', '2.1.1')).to eq(-1)

subject.compare_versions('2.1.1', '1.1.2').should == 1
subject.compare_versions('1.1.2', '2.1.1').should == -1
expect(subject.compare_versions('2.1.1', '1.1.2')).to eq(1)
expect(subject.compare_versions('1.1.2', '2.1.1')).to eq(-1)

subject.compare_versions('1.2.4', '1.2.3').should == 1
subject.compare_versions('1.2.3', '1.2.4').should == -1
expect(subject.compare_versions('1.2.4', '1.2.3')).to eq(1)
expect(subject.compare_versions('1.2.3', '1.2.4')).to eq(-1)

subject.compare_versions('1.2.1', '1.2' ).should == 1
subject.compare_versions('1.2', '1.2.1').should == -1
expect(subject.compare_versions('1.2.1', '1.2' )).to eq(1)
expect(subject.compare_versions('1.2', '1.2.1')).to eq(-1)

subject.compare_versions('1.1.1.pre1', '1.1.1').should == 1
subject.compare_versions('1.1.1', '1.1.1.pre1').should == -1
expect(subject.compare_versions('1.1.1.pre1', '1.1.1')).to eq(1)
expect(subject.compare_versions('1.1.1', '1.1.1.pre1')).to eq(-1)

subject.compare_versions('1.1.1.pre2', '1.1.1.pre1').should == 1
subject.compare_versions('1.1.1.pre1', '1.1.1.pre2').should == -1
expect(subject.compare_versions('1.1.1.pre2', '1.1.1.pre1')).to eq(1)
expect(subject.compare_versions('1.1.1.pre1', '1.1.1.pre2')).to eq(-1)
end
end

shared_context 'with released version at 3.9.7' do
describe '::update' do
before do
Excon.stub({:host => 'assets.heroku.com', :path => '/heroku-client/VERSION'}, {:body => "3.9.7\n"})
end
end

shared_context 'with local version at 3.9.6' do
before do
subject.stub(:latest_local_version).and_return('3.9.6')
end
end

shared_context 'with local version at 3.9.7' do
before do
subject.stub(:latest_local_version).and_return('3.9.7')
end
end

describe '::update' do
include_context 'with released version at 3.9.7'

describe 'non-beta' do
before do
Expand All @@ -74,15 +58,19 @@ module Heroku
end

context 'with no update available' do
include_context 'with local version at 3.9.7'
before do
allow(subject).to receive(:latest_local_version).and_return('3.9.7')
end

it 'does not update' do
expect(subject.update(false)).to be_nil
end
end

context 'with an update available' do
include_context 'with local version at 3.9.6'
before do
allow(subject).to receive(:latest_local_version).and_return('3.9.6')
end

it 'updates' do
expect(subject.update(false)).to eq('3.9.7')
Expand All @@ -97,12 +85,24 @@ module Heroku
end

context 'with no update available' do
include_context 'with local version at 3.9.7'
before do
allow(subject).to receive(:latest_local_version).and_return('3.9.7')
end

it 'still updates' do
expect(subject.update(true)).to eq('3.9.7')
end
end

context 'with a beta older than what we have' do
before do
allow(subject).to receive(:latest_local_version).and_return('3.9.8')
end

it 'does not update' do
expect(subject.update(true)).to be_nil
end
end
end
end
end
Expand Down