push/atlas: ATLAS_TOKEN env var works [GH-5489]

This commit is contained in:
Mitchell Hashimoto 2015-07-06 11:01:50 -06:00
parent b5e57a6e83
commit d03b1f6930
2 changed files with 18 additions and 0 deletions

View File

@ -75,6 +75,7 @@ module VagrantPlugins
def finalize! def finalize!
@address = nil if @address == UNSET_VALUE @address = nil if @address == UNSET_VALUE
@token = nil if @token == UNSET_VALUE @token = nil if @token == UNSET_VALUE
@token = ENV["ATLAS_TOKEN"] if !@token && ENV["ATLAS_TOKEN"] != ""
@app = nil if @app == UNSET_VALUE @app = nil if @app == UNSET_VALUE
@dir = "." if @dir == UNSET_VALUE @dir = "." if @dir == UNSET_VALUE
@uploader_path = nil if @uploader_path == UNSET_VALUE @uploader_path = nil if @uploader_path == UNSET_VALUE

View File

@ -12,6 +12,12 @@ describe VagrantPlugins::AtlasPush::Config do
let(:machine) { double("machine") } let(:machine) { double("machine") }
around(:each) do |example|
with_temp_env("ATLAS_TOKEN" => nil) do
example.run
end
end
before do before do
subject.token = "foo" subject.token = "foo"
end end
@ -97,6 +103,17 @@ describe VagrantPlugins::AtlasPush::Config do
end end
end end
context "when a token is in the environment" do
it "uses the token in the Vagrantfile" do
with_temp_env("ATLAS_TOKEN" => "foo") do
subject.finalize!
end
expect(errors).to be_empty
expect(subject.token).to eq("foo")
end
end
context "when no token is given" do context "when no token is given" do
before do before do
allow(subject).to receive(:token_from_vagrant_login) allow(subject).to receive(:token_from_vagrant_login)