From d03b1f6930c4e706dc4bc7e5e92acd367d0447eb Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 6 Jul 2015 11:01:50 -0600 Subject: [PATCH] push/atlas: ATLAS_TOKEN env var works [GH-5489] --- plugins/pushes/atlas/config.rb | 1 + test/unit/plugins/pushes/atlas/config_test.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/plugins/pushes/atlas/config.rb b/plugins/pushes/atlas/config.rb index 55543fae6..0bedf5d80 100644 --- a/plugins/pushes/atlas/config.rb +++ b/plugins/pushes/atlas/config.rb @@ -75,6 +75,7 @@ module VagrantPlugins def finalize! @address = nil if @address == UNSET_VALUE @token = nil if @token == UNSET_VALUE + @token = ENV["ATLAS_TOKEN"] if !@token && ENV["ATLAS_TOKEN"] != "" @app = nil if @app == UNSET_VALUE @dir = "." if @dir == UNSET_VALUE @uploader_path = nil if @uploader_path == UNSET_VALUE diff --git a/test/unit/plugins/pushes/atlas/config_test.rb b/test/unit/plugins/pushes/atlas/config_test.rb index 580a39ab0..64240f0a0 100644 --- a/test/unit/plugins/pushes/atlas/config_test.rb +++ b/test/unit/plugins/pushes/atlas/config_test.rb @@ -12,6 +12,12 @@ describe VagrantPlugins::AtlasPush::Config do let(:machine) { double("machine") } + around(:each) do |example| + with_temp_env("ATLAS_TOKEN" => nil) do + example.run + end + end + before do subject.token = "foo" end @@ -97,6 +103,17 @@ describe VagrantPlugins::AtlasPush::Config do 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 before do allow(subject).to receive(:token_from_vagrant_login)