Skip to content

Commit

Permalink
tdl - refactoring export_string to export_as_json
Browse files Browse the repository at this point in the history
  • Loading branch information
lzap committed Oct 17, 2011
1 parent 6ee681f commit 514b8f9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/app/controllers/api/templates_controller.rb
Expand Up @@ -84,7 +84,7 @@ def import
end

def export
json = @template.string_export
json = @template.export_as_json
render :json => json
end

Expand Down
4 changes: 2 additions & 2 deletions src/app/models/system_template.rb
Expand Up @@ -87,7 +87,7 @@ def string_import content
json["parameters"].each_pair {|k,v| self.parameters[k] = v } if json["parameters"]
end

def hash_export
def export_as_json
tpl = {
:name => self.name,
:revision => self.revision,
Expand Down Expand Up @@ -340,7 +340,7 @@ def get_inheritance_chain
def copy_to_env env
new_tpl = SystemTemplate.new
new_tpl.environment = env
new_tpl.string_import(self.string_export)
new_tpl.string_import(self.export_as_json)
new_tpl.save!
end

Expand Down
2 changes: 1 addition & 1 deletion src/spec/controllers/api/templates_controller_spec.rb
Expand Up @@ -182,7 +182,7 @@

describe "export" do
it "should call export" do
@tpl.should_receive(:string_export)
@tpl.should_receive(:export_as_json)

get :export, :id => TEMPLATE_ID
end
Expand Down
2 changes: 1 addition & 1 deletion src/spec/models/system_template_spec.rb
Expand Up @@ -274,7 +274,7 @@
@export_tpl.stub(:package_groups).and_return [SystemTemplatePackGroup.new({:name => 'xxx'})]
@export_tpl.stub(:pg_categories).and_return [SystemTemplatePgCategory.new({:name => 'xxx'})]

str = @export_tpl.string_export
str = @export_tpl.export_as_json
json = ActiveSupport::JSON.decode(str)
json['products'].size.should == 2
json['packages'].size.should == 1
Expand Down

0 comments on commit 514b8f9

Please sign in to comment.