Skip to content

Commit

Permalink
Allow passing arguments to console subcommand
Browse files Browse the repository at this point in the history
The `console` subcommand can't take arguments, which prevents the easy
use of the `--sandbox` feature on staging and production consoles to
check things with confidence that production data isn't being
accidentally changed.

This change appends post-`console` arguments as arguments on Heroku.
  • Loading branch information
geoffharcourt committed Apr 2, 2019
1 parent 565d114 commit 0ec56e9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/parity/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ def from_development?
end

def console
Kernel.system(command_for_remote("run bundle exec rails console"))
Kernel.system(
command_for_remote(
"run bundle exec rails console #{arguments.join(' ')}",
),
)
end

def migrate
Expand Down
12 changes: 11 additions & 1 deletion spec/parity/environment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@
expect(Kernel).to have_received(:system).with(heroku_console)
end

it "passes arguments to the console subcommand" do
Parity::Environment.new("production", ["console", "--sandbox"]).run

expect(Kernel).to have_received(:system).with(heroku_console_with_sandbox)
end

it "automatically restarts processes when it migrates the database" do
Parity::Environment.new("production", ["migrate"]).run

Expand Down Expand Up @@ -221,7 +227,11 @@ def heroku_backup
end

def heroku_console
"heroku run bundle exec rails console --remote production"
"heroku run bundle exec rails console --remote production"
end

def heroku_console_with_sandbox
"heroku run bundle exec rails console --sandbox --remote production"
end

def git_push
Expand Down

0 comments on commit 0ec56e9

Please sign in to comment.