Skip to content

Commit abf91dd

Browse files
thbishopdanielsdeleo
authored andcommitted
[CHEF-1518] refactored action detection in subversion resource to avoid checking for revision if we're exporting. updated tests accordingly.
1 parent f27f468 commit abf91dd

2 files changed

Lines changed: 12 additions & 18 deletions

File tree

chef/lib/chef/provider/subversion.rb

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,8 @@ class Subversion < Chef::Provider
3030

3131
def load_current_resource
3232
@current_resource = Chef::Resource::Subversion.new(@new_resource.name)
33-
34-
case @new_resource.action
35-
when Array
36-
derived_action = @new_resource.action.first
37-
when Symbol
38-
derived_action = @new_resource.action
39-
end
40-
41-
unless [:export, :force_export].include?(derived_action)
33+
34+
unless [:export, :force_export].include?(@new_resource.action.first)
4235
if current_revision = find_current_revision
4336
@current_resource.revision current_revision
4437
end

chef/spec/unit/provider/subversion_spec.rb

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@
9090

9191
end
9292

93-
it "creates the current_resource object and sets its revision to the current deployment's revision" do
93+
it "creates the current_resource object and sets its revision to the current deployment's revision as long as we're not exporting" do
9494
@provider.stub!(:find_current_revision).and_return("11410")
95+
@provider.new_resource.instance_variable_set :@action, [:checkout]
9596
@provider.load_current_resource
9697
@provider.current_resource.name.should eql(@resource.name)
9798
@provider.current_resource.revision.should eql("11410")
@@ -166,33 +167,33 @@
166167
@provider.checkout_command.should eql("svn checkout --no-auth-cache -q -r12345 "+
167168
"http://svn.example.org/trunk/ /my/deploy/dir")
168169
end
169-
170+
170171
it "generates a sync command with default options" do
171172
@provider.sync_command.should eql("svn update -q -r12345 /my/deploy/dir")
172173
end
173-
174+
174175
it "generates an export command with default options" do
175176
@provider.export_command.should eql("svn export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir")
176177
end
177-
178+
178179
it "doesn't try to find the current revision when loading the resource if running an export" do
179-
@provider.new_resource.instance_variable_set :@action, :export
180+
@provider.new_resource.instance_variable_set :@action, [:export]
180181
@provider.should_not_receive(:find_current_revision)
181182
@provider.load_current_resource
182183
end
183-
184+
184185
it "doesn't try to find the current revision when loading the resource if running a force export" do
185-
@provider.new_resource.instance_variable_set :@action, :force_export
186+
@provider.new_resource.instance_variable_set :@action, [:force_export]
186187
@provider.should_not_receive(:find_current_revision)
187188
@provider.load_current_resource
188189
end
189-
190+
190191
it "runs an export with the --force option" do
191192
expected_cmd = "svn export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
192193
@provider.should_receive(:run_command).with(:command => expected_cmd)
193194
@provider.action_force_export
194195
end
195-
196+
196197
it "runs the checkout command for action_checkout" do
197198
expected_cmd = "svn checkout -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
198199
@provider.should_receive(:run_command).with(:command => expected_cmd)

0 commit comments

Comments
 (0)