-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse git remote name to determine Heroku app
Several reports have matched #72, which was affecting the `restore` command for some users. The cause turned out to be local folder names not matching the name of the Heroku app. Now that Heroku tracks Git remotes, we can take advantage of the Git remote to correctly identify the app name even the local folder name doesn't match. While this requirement has existed for the entirety of Parity's existence, it stopped being a problem for most commands once Heroku introduced remotes. I inadvertently reintroduced this requirement in ad2c21a when we started automatically bypassing confirmation arguments for restores to non-production environments. Fix #72.
- Loading branch information
1 parent
95ac59c
commit 1d3ae15
Showing
5 changed files
with
40 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ source 'https://rubygems.org' | |
|
||
gemspec | ||
|
||
gem 'rake' | ||
gem 'rspec' | ||
gem "git" | ||
gem "rake" | ||
gem "rspec" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,26 @@ | |
expect(Kernel).to have_received(:system).with(heroku_backup) | ||
end | ||
|
||
it "correctly connects to the right Heroku app when the local folder's name does not match the Heroku app's name" do | ||
backup = double("backup", restore: nil) | ||
stub_git_remote(base_name: "parity-integration", environment: "staging") | ||
allow(Parity::Backup).to receive(:new).and_return(backup) | ||
|
||
Parity::Environment.new("staging", ["restore", "production"]).run | ||
|
||
expect(Parity::Backup). | ||
to have_received(:new). | ||
with( | ||
from: "production", | ||
to: "staging", | ||
additional_args: "--confirm parity-integration-staging", | ||
) | ||
expect(backup).to have_received(:restore) | ||
end | ||
|
||
it "restores backups from production to staging" do | ||
backup = double("backup", restore: nil) | ||
stub_git_remote(environment: "staging") | ||
allow(Parity::Backup).to receive(:new).and_return(backup) | ||
|
||
Parity::Environment.new("staging", ["restore", "production"]).run | ||
|
@@ -49,6 +67,7 @@ | |
|
||
it "restores using restore-from" do | ||
backup = double("backup", restore: nil) | ||
stub_git_remote(environment: "staging") | ||
allow(Parity::Backup).to receive(:new).and_return(backup) | ||
|
||
Parity::Environment.new("staging", ["restore-from", "production"]).run | ||
|
@@ -65,6 +84,7 @@ | |
|
||
it "passes the confirm argument when restoring to a non-prod environment" do | ||
backup = double("backup", restore: nil) | ||
stub_git_remote(environment: "staging") | ||
allow(Parity::Backup).to receive(:new).and_return(backup) | ||
|
||
Parity::Environment.new("staging", ["restore", "production"]).run | ||
|
@@ -102,6 +122,7 @@ | |
|
||
it "does not allow restoring backups into production" do | ||
backup = double("backup", restore: nil) | ||
stub_git_remote | ||
allow(Parity::Backup).to receive(:new).and_return(backup) | ||
allow($stdout).to receive(:puts) | ||
|
||
|
@@ -323,4 +344,14 @@ def stub_migration_path_check(result) | |
|
||
path_stub | ||
end | ||
|
||
def stub_git_remote(base_name: "parity", environment: "staging") | ||
git_remote = double( | ||
"Git::Remote", | ||
url: "[email protected]:#{base_name}-#{environment}.git", | ||
) | ||
git = double("Git") | ||
allow(git).to receive(:remote).with("staging").and_return(git_remote) | ||
allow(Git).to receive(:init).and_return(git) | ||
end | ||
end |