brandmaker 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,89 @@
1
+ require 'spec_helper'
2
+
3
+ describe Brandmaker::Job do
4
+
5
+ let :job do
6
+ Brandmaker::Job.new main_job_data
7
+ end
8
+
9
+ let :job_config do
10
+ nil
11
+ end
12
+
13
+ describe '#id' do
14
+ it 'returns the id' do
15
+ job.id.should == '8193'
16
+ end
17
+ end
18
+
19
+ describe '#technical_name' do
20
+ it 'returns the technical_name' do
21
+ job.technical_name.should == 'screenconcept__hauptjob'
22
+ end
23
+ end
24
+
25
+ around :each do |example|
26
+ Brandmaker.configure do |config|
27
+ config.job_configs[:screenconcept__hauptjob] = job_config
28
+ end
29
+
30
+ example.run
31
+
32
+ Brandmaker.configure do |config|
33
+ config.job_configs.delete :screenconcept__hauptjob
34
+ end
35
+ end
36
+
37
+ describe '#config' do
38
+ context 'when a job config exists' do
39
+ let :job_config do
40
+ Brandmaker::JobConfig.new(job.technical_name)
41
+ end
42
+
43
+ it 'returns the job config' do
44
+ job.config.should == job_config
45
+ end
46
+ end
47
+
48
+ context 'when no job config exists' do
49
+ it 'raises an exception' do
50
+ expect { job.config }.to raise_error "Job #{job.id} is not configured, no config for #{job.technical_name}"
51
+ end
52
+ end
53
+ end
54
+
55
+ describe '#variables' do
56
+ let :job_config do
57
+ Brandmaker::JobConfig.new job.technical_name, [
58
+ Brandmaker::VariableConfig.new(:name => 'default_media'),
59
+ Brandmaker::VariableConfig.new(:name => 'some_email_recipient', :purpose => Brandmaker::VariablePurpose::EMAIL_RECIPIENT)
60
+ ]
61
+ end
62
+
63
+ before :each do
64
+ Brandmaker.configure do |config|
65
+ config.job_configs[:screenconcept__hauptjob] = job_config
66
+ end
67
+ end
68
+
69
+ it 'returns all variables which are configured in the job config' do
70
+ job.variables.count.should be(1)
71
+ end
72
+
73
+ it 'returns a list of Variables' do
74
+ job.variables.should be_all { |v| v.should be_a(Brandmaker::Variable) }
75
+ end
76
+ end
77
+
78
+ describe '#recipients' do
79
+ let :job_config do
80
+ Brandmaker::JobConfig.new job.technical_name, [
81
+ Brandmaker::VariableConfig.new(:name => 'email_field1', :purpose => Brandmaker::VariablePurpose::EMAIL_RECIPIENT)
82
+ ]
83
+ end
84
+
85
+ it 'returns an array' do
86
+ job.recipients.should == %w(test@test.com)
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,206 @@
1
+ # encoding: utf-8
2
+
3
+ module Brandmaker
4
+ module SeedData
5
+
6
+ def main_job_data
7
+ {
8
+ :processing_time=>"0",
9
+ :success=>true,
10
+ :desriptions=> {
11
+ :creator=>"Screenconcept",
12
+ :id=>"8193",
13
+ :topic_name=>"Job",
14
+ :type_name=>"screenconcept__hauptjob",
15
+ :variable=> [
16
+ {
17
+ :technical_name=>"WorkflowOverdueDate",
18
+ :value=> '20.04.2015',
19
+ :variable_type_id=>"-115"
20
+ },
21
+ {
22
+ :technical_name=>"default_media",
23
+ :value=> 'Some Value',
24
+ :variable_type_id=>"-2008"
25
+ },
26
+ {
27
+ :technical_name=>"medienobjektauswahl",
28
+ :value=>"7961,7270",
29
+ :variable_type_id=>"11111"
30
+ },
31
+ {
32
+ :technical_name=>"email_field1",
33
+ :value=>"test@test.com",
34
+ :variable_type_id=>"11112"
35
+ },
36
+ {
37
+ :technical_name=>"email_field2",
38
+ :value=>"Email Subject",
39
+ :variable_type_id=>"11113"
40
+ },
41
+ {
42
+ :technical_name=>"email_field3",
43
+ :value=>"Email message",
44
+ :variable_type_id=>"11114"
45
+ },
46
+ {
47
+ :sub_jobs=> {
48
+ :sub_job=> {
49
+ :creator=>"Screenconcept",
50
+ :id=>"8194",
51
+ :topic_name=>"Job",
52
+ :type_name=>"screenconcept__subjob",
53
+ :variable=> [
54
+ {
55
+ :technical_name=>"WorkflowOverdueDate",
56
+ :value=>nil,
57
+ :variable_type_id=>"-115"
58
+ },
59
+ {
60
+ :technical_name=>"default_media",
61
+ :value=>nil,
62
+ :variable_type_id=>"-2008"
63
+ },
64
+ ],
65
+ :workflow_step_name=>"Start",
66
+ :workflow_type_name=>"Screenconcept - Testworkflow"
67
+ }
68
+ },
69
+ :technical_name=>"SubJobs",
70
+ :value=>nil,
71
+ :variable_type_id=>"-105"
72
+ },
73
+ grid_variable_data,
74
+ {
75
+ :technical_name=>"TaskManager",
76
+ :value=>nil,
77
+ :variable_type_id=>"11047"
78
+ },
79
+ ],
80
+ :workflow_step_name=>"Start",
81
+ :workflow_type_name=>"Screenconcept - Testworkflow"
82
+ }
83
+ }
84
+ end
85
+
86
+ def grid_variable_data
87
+ {
88
+ :grid=>
89
+ {
90
+ :row=>
91
+ [{
92
+ :id=>"7898",
93
+ :topic_name=>"Job",
94
+ :variable=>
95
+ {
96
+ :technical_name=>"emailadresse",
97
+ :value=>"Immanuel",
98
+ :variable_type_id=>"11247"
99
+ }
100
+ },
101
+ {
102
+ :id=>"7899",
103
+ :topic_name=>"Job",
104
+ :variable=>
105
+ {
106
+ :technical_name=>"emailadresse",
107
+ :value=>"Michi",
108
+ :variable_type_id=>"11247"
109
+ }
110
+ }
111
+ ]
112
+ },
113
+ :technical_name=>"email_selection",
114
+ :value=>nil,
115
+ :variable_type_id=>"11245"
116
+ }
117
+ end
118
+
119
+ def grid_variable_single_row_data
120
+ {
121
+ :grid=>
122
+ {
123
+ :row=>
124
+ {
125
+ :id=>"7898",
126
+ :topic_name=>"Job",
127
+ :variable=>
128
+ {
129
+ :technical_name=>"emailadresse",
130
+ :value=>"Immanuel",
131
+ :variable_type_id=>"11247"
132
+ }
133
+ }
134
+ },
135
+ :technical_name=>"email_selection",
136
+ :value=>nil,
137
+ :variable_type_id=>"11245"
138
+ }
139
+ end
140
+
141
+ def grid_variable_email_data
142
+ {
143
+ :grid=>
144
+ {
145
+ :row=>
146
+ [{
147
+ :id=>"7898",
148
+ :topic_name=>"Job",
149
+ :variable=>
150
+ {
151
+ :technical_name=>"emailadresse",
152
+ :value=>"Immanuel (immanuel.haeussermann@screenconcept.ch)",
153
+ :variable_type_id=>"11247"
154
+ }
155
+ },
156
+ {
157
+ :id=>"7899",
158
+ :topic_name=>"Job",
159
+ :variable=>
160
+ {
161
+ :technical_name=>"emailadresse",
162
+ :value=>"Michi (michael.friedli@gateb.com)",
163
+ :variable_type_id=>"11247"
164
+ }
165
+ }
166
+ ]
167
+ },
168
+ :technical_name=>"email_selection",
169
+ :value=>nil,
170
+ :variable_type_id=>"11245"
171
+ }
172
+ end
173
+
174
+ def custom_structure_all_data
175
+ {:find_all_custom_structures_response=>
176
+ {:return=>
177
+ {:processing_time=>"0",
178
+ :success=>true,
179
+ :custom_structures=>
180
+ [
181
+ custom_structure_external_suppliers_data
182
+ ]}}}
183
+ end
184
+
185
+ def custom_structure_all_empty_data
186
+ {:find_all_custom_structures_response=>
187
+ {:return=>
188
+ {:processing_time=>"0",
189
+ :success=>true,
190
+ :custom_structures=>
191
+ []}}}
192
+ end
193
+
194
+ def custom_structure_external_suppliers_data
195
+ {:label=>"PM_ExterneSuppliers_Druckereien",
196
+ :name=>"PM_ExterneSuppliers_Druckereien",
197
+ :objects=>
198
+ [{:label=>"Demo Druck (immanuel.haeussermann@screenconcept.ch)",
199
+ :name=>"Demo Druck"},
200
+ {:label=>"Demo Druck 2 (michael.friedli@gateb.com)",
201
+ :name=>"Demo Druck 2"}
202
+ ]}
203
+ end
204
+
205
+ end
206
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe Brandmaker::VariableCollection do
4
+
5
+ let :collection do
6
+ Brandmaker::VariableCollection.new([
7
+ { :technical_name => 'one' },
8
+ { :technical_name => 'two', :purpose => Brandmaker::VariablePurpose::EMAIL_RECIPIENT },
9
+ { :technical_name => 'three' }
10
+ ])
11
+ end
12
+
13
+ describe '#initialize' do
14
+ it 'collects JobVariables' do
15
+ collection.count.should be(3)
16
+ end
17
+ end
18
+
19
+ describe '#find_by_technical_name' do
20
+ context 'when the variable exists in the collection' do
21
+ it 'returns the variable' do
22
+ collection.find_by_technical_name('two').should be_a(Brandmaker::Variable)
23
+ end
24
+ end
25
+
26
+ context 'when the variable does not exist in the collection' do
27
+ it 'returns nil' do
28
+ collection.find_by_technical_name('five').should be_nil
29
+ end
30
+ end
31
+ end
32
+
33
+ describe '#find_by_purpose' do
34
+ context 'when the variable exists in the collection' do
35
+ it 'returns the variable' do
36
+ collection.find_by_purpose(Brandmaker::VariablePurpose::EMAIL_RECIPIENT).should be_a(Brandmaker::Variable)
37
+ end
38
+ end
39
+
40
+ context 'when the variable does not exist in the collection' do
41
+ it 'raises an exception' do
42
+ expect { collection.find_by_purpose(Brandmaker::VariablePurpose::EMAIL_MESSAGE) }.to raise_error "#{Brandmaker::VariablePurpose::EMAIL_MESSAGE} is not configured for this job"
43
+ end
44
+ end
45
+ end
46
+
47
+ describe '#unporposed' do
48
+ it 'returns all variables without purpose' do
49
+ collection.unpurposed.length.should be(2)
50
+ end
51
+
52
+ it 'returns a VariableCollection' do
53
+ collection.unpurposed.should be_a(Brandmaker::VariableCollection)
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ module Brandmaker
4
+ describe Variable do
5
+
6
+ describe '#purpose' do
7
+ let :purpose do
8
+ 'purpose'
9
+ end
10
+
11
+ context 'when API provides purpose' do
12
+ let :variable do
13
+ Variable.new({ :purpose => purpose })
14
+ end
15
+
16
+ it 'returns purpose from API' do
17
+ variable.purpose.should == purpose
18
+ end
19
+ end
20
+
21
+ context 'when API provides no purpose' do
22
+ let :variable do
23
+ Variable.new({}).tap do |v|
24
+ v.config = VariableConfig.new({ :purpose => purpose })
25
+ end
26
+ end
27
+
28
+ it 'returns purpose from variable config' do
29
+ variable.purpose.should be(purpose)
30
+ end
31
+ end
32
+
33
+ context 'when neither API nor config provides purpose' do
34
+ let :variable do
35
+ Variable.new({})
36
+ end
37
+
38
+ it 'returns nil' do
39
+ variable.purpose.should be_nil
40
+ end
41
+ end
42
+ end
43
+
44
+ describe '#label' do
45
+ let :variable do
46
+ Variable.new({:technical_name => 'technical_name'})
47
+ end
48
+
49
+ context 'when label is configured' do
50
+ it 'returns configured label' do
51
+ variable.config = VariableConfig.new({ :label => 'label' })
52
+ variable.label.should == 'label'
53
+ end
54
+ end
55
+
56
+ context 'when label is not configured' do
57
+ it 'returns humanized technical_name' do
58
+ variable.label.should == 'Technical name'
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+
@@ -0,0 +1,18 @@
1
+ require 'brandmaker'
2
+ require 'brandmaker/seed_data'
3
+
4
+ require 'pry'
5
+
6
+ RSpec.configure do |config|
7
+ config.treat_symbols_as_metadata_keys_with_true_values = true
8
+ config.run_all_when_everything_filtered = true
9
+ config.filter_run :focus
10
+
11
+ # Run specs in random order to surface order dependencies. If you find an
12
+ # order dependency and want to debug it, you can fix the order by providing
13
+ # the seed, which is printed after each run.
14
+ # --seed 1234
15
+ config.order = 'random'
16
+
17
+ config.include Brandmaker::SeedData
18
+ end
metadata ADDED
@@ -0,0 +1,167 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: brandmaker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Immanuel Häussermann
8
+ - Sebastian de Castelberg
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: savon
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: 1.2.0
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: 1.2.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: activesupport
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rest-client
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: json
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: pry
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ description: Allows access to BrandMaker JobManager (DSE) and MediaPool APIs
99
+ email:
100
+ - developers@screenconcept.ch
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - .gitignore
106
+ - .rspec
107
+ - CHANGELOG.md
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - brandmaker.gemspec
113
+ - lib/brandmaker.rb
114
+ - lib/brandmaker/configuration.rb
115
+ - lib/brandmaker/custom_structure.rb
116
+ - lib/brandmaker/external_media_variable.rb
117
+ - lib/brandmaker/grid_variable.rb
118
+ - lib/brandmaker/job.rb
119
+ - lib/brandmaker/job_config.rb
120
+ - lib/brandmaker/media_variable.rb
121
+ - lib/brandmaker/variable.rb
122
+ - lib/brandmaker/variable_collection.rb
123
+ - lib/brandmaker/variable_config.rb
124
+ - lib/brandmaker/variable_purpose.rb
125
+ - lib/brandmaker/version.rb
126
+ - spec/brandmaker/configuration_spec.rb
127
+ - spec/brandmaker/custom_structure_spec.rb
128
+ - spec/brandmaker/external_media_variable_spec.rb
129
+ - spec/brandmaker/grid_variable_spec.rb
130
+ - spec/brandmaker/job_spec.rb
131
+ - spec/brandmaker/seed_data.rb
132
+ - spec/brandmaker/variable_collection_spec.rb
133
+ - spec/brandmaker/variable_spec.rb
134
+ - spec/spec_helper.rb
135
+ homepage: https://github.com/screenconcept/brandmaker
136
+ licenses: []
137
+ metadata: {}
138
+ post_install_message:
139
+ rdoc_options: []
140
+ require_paths:
141
+ - lib
142
+ required_ruby_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ required_rubygems_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - '>='
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ requirements: []
153
+ rubyforge_project:
154
+ rubygems_version: 2.0.3
155
+ signing_key:
156
+ specification_version: 4
157
+ summary: Ruby based BrandMaker API
158
+ test_files:
159
+ - spec/brandmaker/configuration_spec.rb
160
+ - spec/brandmaker/custom_structure_spec.rb
161
+ - spec/brandmaker/external_media_variable_spec.rb
162
+ - spec/brandmaker/grid_variable_spec.rb
163
+ - spec/brandmaker/job_spec.rb
164
+ - spec/brandmaker/seed_data.rb
165
+ - spec/brandmaker/variable_collection_spec.rb
166
+ - spec/brandmaker/variable_spec.rb
167
+ - spec/spec_helper.rb