Skip to content

Commit

Permalink
Added blank check in representers for build task attributes. (#2753)
Browse files Browse the repository at this point in the history
  • Loading branch information
varshavaradarajan committed Oct 4, 2016
1 parent 75ab962 commit d646cfc
Show file tree
Hide file tree
Showing 12 changed files with 250 additions and 40 deletions.
@@ -1,5 +1,5 @@
##########################################################################
# Copyright 2015 ThoughtWorks, Inc.
# Copyright 2016 ThoughtWorks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -23,13 +23,12 @@ class AntTaskRepresenter < ApiV1::Config::Tasks::BaseTaskRepresenter
'workingDirectory' => 'working_directory',
'buildFile' => 'build_file',
'onCancelConfig' => 'on_cancel',
'runIf' => 'run_if',
'nantPath' => 'nant_path'
'runIf' => 'run_if'
}

property :working_directory
property :build_file
property :target
property :working_directory, skip_parse: SkipParseOnBlank
property :build_file, skip_parse: SkipParseOnBlank
property :target, skip_parse: SkipParseOnBlank

end
end
Expand Down
@@ -1,5 +1,5 @@
##########################################################################
# Copyright 2015 ThoughtWorks, Inc.
# Copyright 2016 ThoughtWorks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,10 +27,10 @@ class NantTaskRepresenter < ApiV1::Config::Tasks::BaseTaskRepresenter
'nantPath' => 'nant_path'
}

property :working_directory
property :build_file
property :target
property :nant_path
property :working_directory, skip_parse: SkipParseOnBlank
property :build_file, skip_parse: SkipParseOnBlank
property :target, skip_parse: SkipParseOnBlank
property :nant_path, skip_parse: SkipParseOnBlank


end
Expand Down
@@ -1,5 +1,5 @@
##########################################################################
# Copyright 2015 ThoughtWorks, Inc.
# Copyright 2016 ThoughtWorks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -26,9 +26,9 @@ class RakeTaskRepresenter < ApiV1::Config::Tasks::BaseTaskRepresenter
'runIf' => 'run_if'
}

property :working_directory
property :build_file
property :target
property :working_directory, skip_parse: SkipParseOnBlank
property :build_file, skip_parse: SkipParseOnBlank
property :target, skip_parse: SkipParseOnBlank

end
end
Expand Down
Expand Up @@ -23,13 +23,12 @@ class AntTaskRepresenter < ApiV2::Config::Tasks::BaseTaskRepresenter
'workingDirectory' => 'working_directory',
'buildFile' => 'build_file',
'onCancelConfig' => 'on_cancel',
'runIf' => 'run_if',
'nantPath' => 'nant_path'
'runIf' => 'run_if'
}

property :working_directory
property :build_file
property :target
property :working_directory, skip_parse: SkipParseOnBlank
property :build_file, skip_parse: SkipParseOnBlank
property :target, skip_parse: SkipParseOnBlank

end
end
Expand Down
Expand Up @@ -27,10 +27,10 @@ class NantTaskRepresenter < ApiV2::Config::Tasks::BaseTaskRepresenter
'nantPath' => 'nant_path'
}

property :working_directory
property :build_file
property :target
property :nant_path
property :working_directory, skip_parse: SkipParseOnBlank
property :build_file, skip_parse: SkipParseOnBlank
property :target, skip_parse: SkipParseOnBlank
property :nant_path, skip_parse: SkipParseOnBlank


end
Expand Down
Expand Up @@ -26,9 +26,9 @@ class RakeTaskRepresenter < ApiV2::Config::Tasks::BaseTaskRepresenter
'runIf' => 'run_if'
}

property :working_directory
property :build_file
property :target
property :working_directory, skip_parse: SkipParseOnBlank
property :build_file, skip_parse: SkipParseOnBlank
property :target, skip_parse: SkipParseOnBlank

end
end
Expand Down
Expand Up @@ -23,13 +23,12 @@ class AntTaskRepresenter < ApiV3::Config::Tasks::BaseTaskRepresenter
'workingDirectory' => 'working_directory',
'buildFile' => 'build_file',
'onCancelConfig' => 'on_cancel',
'runIf' => 'run_if',
'nantPath' => 'nant_path'
'runIf' => 'run_if'
}

property :working_directory
property :build_file
property :target
property :working_directory, skip_parse: SkipParseOnBlank
property :build_file, skip_parse: SkipParseOnBlank
property :target, skip_parse: SkipParseOnBlank

end
end
Expand Down
Expand Up @@ -27,10 +27,10 @@ class NantTaskRepresenter < ApiV3::Config::Tasks::BaseTaskRepresenter
'nantPath' => 'nant_path'
}

property :working_directory
property :build_file
property :target
property :nant_path
property :working_directory, skip_parse: SkipParseOnBlank
property :build_file, skip_parse: SkipParseOnBlank
property :target, skip_parse: SkipParseOnBlank
property :nant_path, skip_parse: SkipParseOnBlank


end
Expand Down
Expand Up @@ -26,9 +26,9 @@ class RakeTaskRepresenter < ApiV3::Config::Tasks::BaseTaskRepresenter
'runIf' => 'run_if'
}

property :working_directory
property :build_file
property :target
property :working_directory, skip_parse: SkipParseOnBlank
property :build_file, skip_parse: SkipParseOnBlank
property :target, skip_parse: SkipParseOnBlank

end
end
Expand Down
@@ -1,5 +1,5 @@
##########################################################################
# Copyright 2015 ThoughtWorks, Inc.
# Copyright 2016 ThoughtWorks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -161,6 +161,17 @@ def task_hash
}
end

def default_task_hash
{
type: 'ant',
attributes: {
working_directory: '',
build_file: '',
target: ' '
}
}
end

it 'should represent errors' do
task = AntTask.new()
task.setWorkingDirectory("../outside")
Expand All @@ -178,6 +189,18 @@ def task_hash
expect(errors_hash[:errors].keys.size).to eq(task.errors.size)
end

it 'should represent the ant task attributes as null if blank' do
task = AntTask.new
ApiV1::Config::Tasks::TaskRepresenter.new(task).from_hash(default_task_hash)
actual_json = ApiV1::Config::Tasks::TaskRepresenter.new(task).to_hash(url_builder: UrlBuilder.new)
expect(task.getTarget).to eq(nil)
expect(task.getBuildFile).to eq(nil)
expect(task.workingDirectory).to eq(nil)
expect(actual_json).to eq({ type: 'ant',
attributes: {run_if: [], on_cancel: nil, working_directory: nil, build_file: nil, target: nil}
})
end

def errors_hash
{
type: 'ant',
Expand Down Expand Up @@ -214,6 +237,18 @@ def task_hash
}
end

def default_task_hash
{
type: 'nant',
attributes: {
working_directory: '',
build_file: '',
target: ' ',
nant_path: ''
}
}
end

it 'should represent errors' do
task = NantTask.new()
task.setWorkingDirectory("../outside")
Expand All @@ -231,6 +266,18 @@ def task_hash
expect(errors_hash[:errors].keys.size).to eq(task.errors.size)
end

it 'should represent the nant task attributes as null if blank' do
task = NantTask.new
ApiV1::Config::Tasks::TaskRepresenter.new(task).from_hash(default_task_hash)
actual_json = ApiV1::Config::Tasks::TaskRepresenter.new(task).to_hash(url_builder: UrlBuilder.new)
expect(task.getTarget).to eq(nil)
expect(task.getBuildFile).to eq(nil)
expect(task.workingDirectory).to eq(nil)
expect(actual_json).to eq({ type: 'nant',
attributes: {run_if: [], on_cancel: nil, working_directory: nil, build_file: nil, target: nil, nant_path: nil}
})
end

def errors_hash
{
type: 'nant',
Expand Down Expand Up @@ -266,6 +313,18 @@ def task_hash
}
end

def default_task_hash
{
type: 'rake',
attributes: {
working_directory: '',
build_file: '',
target: ' ',
nant_path: ''
}
}
end

it 'should represent errors' do
task = RakeTask.new()
task.setWorkingDirectory("../outside")
Expand All @@ -283,6 +342,18 @@ def task_hash
expect(errors_hash[:errors].keys.size).to eq(task.errors.size)
end

it 'should represent the rake task attributes as null if not provided' do
task = RakeTask.new
ApiV1::Config::Tasks::TaskRepresenter.new(task).from_hash(default_task_hash)
actual_json = ApiV1::Config::Tasks::TaskRepresenter.new(task).to_hash(url_builder: UrlBuilder.new)
expect(task.getTarget).to eq(nil)
expect(task.getBuildFile).to eq(nil)
expect(task.workingDirectory).to eq(nil)
expect(actual_json).to eq({type: 'rake',
attributes: {run_if: [], on_cancel: nil, working_directory: nil, build_file: nil, target: nil}
})
end

def errors_hash
{
type: 'rake',
Expand Down
Expand Up @@ -161,6 +161,17 @@ def task_hash
}
end

def default_task_hash
{
type: 'ant',
attributes: {
working_directory: '',
build_file: '',
target: ' '
}
}
end

it 'should represent errors' do
task = AntTask.new()
task.setWorkingDirectory("../outside")
Expand All @@ -178,6 +189,18 @@ def task_hash
expect(errors_hash[:errors].keys.size).to eq(task.errors.size)
end

it 'should represent the ant task attributes as null if blank' do
task = AntTask.new
ApiV2::Config::Tasks::TaskRepresenter.new(task).from_hash(default_task_hash)
actual_json = ApiV2::Config::Tasks::TaskRepresenter.new(task).to_hash(url_builder: UrlBuilder.new)
expect(task.getTarget).to eq(nil)
expect(task.getBuildFile).to eq(nil)
expect(task.workingDirectory).to eq(nil)
expect(actual_json).to eq({ type: 'ant',
attributes: {run_if: [], on_cancel: nil, working_directory: nil, build_file: nil, target: nil}
})
end

def errors_hash
{
type: 'ant',
Expand Down Expand Up @@ -214,6 +237,18 @@ def task_hash
}
end

def default_task_hash
{
type: 'nant',
attributes: {
working_directory: '',
build_file: '',
target: ' ',
nant_path: ''
}
}
end

it 'should represent errors' do
task = NantTask.new()
task.setWorkingDirectory("../outside")
Expand All @@ -231,6 +266,18 @@ def task_hash
expect(errors_hash[:errors].keys.size).to eq(task.errors.size)
end

it 'should represent the nant task attributes as null if blank' do
task = NantTask.new
ApiV2::Config::Tasks::TaskRepresenter.new(task).from_hash(default_task_hash)
actual_json = ApiV2::Config::Tasks::TaskRepresenter.new(task).to_hash(url_builder: UrlBuilder.new)
expect(task.getTarget).to eq(nil)
expect(task.getBuildFile).to eq(nil)
expect(task.workingDirectory).to eq(nil)
expect(actual_json).to eq({ type: 'nant',
attributes: {run_if: [], on_cancel: nil, working_directory: nil, build_file: nil, target: nil, nant_path: nil}
})
end

def errors_hash
{
type: 'nant',
Expand Down Expand Up @@ -266,6 +313,18 @@ def task_hash
}
end

def default_task_hash
{
type: 'rake',
attributes: {
working_directory: '',
build_file: '',
target: ' ',
nant_path: ''
}
}
end

it 'should represent errors' do
task = RakeTask.new()
task.setWorkingDirectory("../outside")
Expand All @@ -283,6 +342,18 @@ def task_hash
expect(errors_hash[:errors].keys.size).to eq(task.errors.size)
end

it 'should represent the rake task attributes as null if not provided' do
task = RakeTask.new
ApiV2::Config::Tasks::TaskRepresenter.new(task).from_hash(default_task_hash)
actual_json = ApiV2::Config::Tasks::TaskRepresenter.new(task).to_hash(url_builder: UrlBuilder.new)
expect(task.getTarget).to eq(nil)
expect(task.getBuildFile).to eq(nil)
expect(task.workingDirectory).to eq(nil)
expect(actual_json).to eq({type: 'rake',
attributes: {run_if: [], on_cancel: nil, working_directory: nil, build_file: nil, target: nil}
})
end

def errors_hash
{
type: 'rake',
Expand Down

0 comments on commit d646cfc

Please sign in to comment.