neuron-client 0.2.6 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/README.md +11 -8
  2. data/lib/neuron-client/api.rb +5 -0
  3. data/lib/neuron-client/model/ad.rb +142 -0
  4. data/lib/neuron-client/model/ad_calculations.rb +325 -0
  5. data/lib/neuron-client/model/ad_zone.rb +45 -0
  6. data/lib/neuron-client/model/base.rb +233 -18
  7. data/lib/neuron-client/model/blocked_referer.rb +20 -0
  8. data/lib/neuron-client/model/blocked_user_agent.rb +21 -0
  9. data/lib/neuron-client/model/geo_target.rb +36 -0
  10. data/lib/neuron-client/model/pixel.rb +22 -0
  11. data/lib/neuron-client/model/report.rb +35 -0
  12. data/lib/neuron-client/model/s3_file.rb +30 -0
  13. data/lib/neuron-client/model/zone.rb +64 -0
  14. data/lib/neuron-client/model/zone_calculations.rb +37 -0
  15. data/lib/neuron-client/schema/ad.rb +406 -0
  16. data/lib/neuron-client/schema/ad_zone.rb +49 -0
  17. data/lib/neuron-client/schema/blocked_referer.rb +52 -0
  18. data/lib/neuron-client/schema/blocked_user_agent.rb +64 -0
  19. data/lib/neuron-client/schema/common.rb +220 -0
  20. data/lib/neuron-client/schema/event.rb +17 -0
  21. data/lib/neuron-client/schema/geo_target.rb +33 -0
  22. data/lib/neuron-client/schema/pixel.rb +39 -0
  23. data/lib/neuron-client/schema/report.rb +59 -0
  24. data/lib/neuron-client/schema/s3_file.rb +87 -0
  25. data/lib/neuron-client/schema/zone.rb +214 -0
  26. data/lib/neuron-client/version.rb +1 -1
  27. data/lib/neuron-client.rb +24 -59
  28. data/neuron-client.gemspec +3 -0
  29. data/spec/lib/admin_connection_spec.rb +234 -0
  30. data/spec/lib/api_spec.rb +41 -63
  31. data/spec/lib/model/ad_calculations_spec.rb +1146 -0
  32. data/spec/lib/model/ad_spec.rb +253 -0
  33. data/spec/lib/model/ad_zone_spec.rb +15 -0
  34. data/spec/lib/model/base_spec.rb +5 -83
  35. data/spec/lib/model/blocked_referer_spec.rb +36 -0
  36. data/spec/lib/model/blocked_user_agent_spec.rb +36 -0
  37. data/spec/lib/model/geo_target_spec.rb +28 -0
  38. data/spec/lib/model/pixel_spec.rb +36 -0
  39. data/spec/lib/model/report_spec.rb +17 -0
  40. data/spec/lib/{s3_file_spec.rb → model/s3_file_spec.rb} +6 -5
  41. data/spec/lib/model/zone_calculations_spec.rb +49 -0
  42. data/spec/lib/model/zone_spec.rb +155 -0
  43. data/spec/lib/schema/ad_spec.rb +515 -0
  44. data/spec/lib/schema/ad_zone_spec.rb +149 -0
  45. data/spec/lib/schema/blocked_referer_spec.rb +136 -0
  46. data/spec/lib/schema/blocked_user_agent_spec.rb +147 -0
  47. data/spec/lib/schema/geo_target_spec.rb +92 -0
  48. data/spec/lib/schema/pixel_spec.rb +125 -0
  49. data/spec/lib/schema/report_spec.rb +129 -0
  50. data/spec/lib/schema/s3_file_spec.rb +164 -0
  51. data/spec/lib/schema/zone_spec.rb +243 -0
  52. data/spec/spec_helper.rb +2 -1
  53. metadata +141 -121
  54. data/lib/neuron-client/model/admin/ad.rb +0 -22
  55. data/lib/neuron-client/model/admin/ad_zone.rb +0 -15
  56. data/lib/neuron-client/model/admin/base.rb +0 -91
  57. data/lib/neuron-client/model/admin/blocked_referer.rb +0 -12
  58. data/lib/neuron-client/model/admin/blocked_user_agent.rb +0 -12
  59. data/lib/neuron-client/model/admin/geo_target.rb +0 -16
  60. data/lib/neuron-client/model/admin/pixel.rb +0 -12
  61. data/lib/neuron-client/model/admin/report.rb +0 -15
  62. data/lib/neuron-client/model/admin/s3_file.rb +0 -12
  63. data/lib/neuron-client/model/admin/zone.rb +0 -15
  64. data/lib/neuron-client/model/common/ad.rb +0 -42
  65. data/lib/neuron-client/model/common/ad_calculations.rb +0 -329
  66. data/lib/neuron-client/model/common/ad_zone.rb +0 -17
  67. data/lib/neuron-client/model/common/base.rb +0 -67
  68. data/lib/neuron-client/model/common/blocked_referer.rb +0 -16
  69. data/lib/neuron-client/model/common/blocked_user_agent.rb +0 -16
  70. data/lib/neuron-client/model/common/geo_target.rb +0 -16
  71. data/lib/neuron-client/model/common/pixel.rb +0 -18
  72. data/lib/neuron-client/model/common/report.rb +0 -21
  73. data/lib/neuron-client/model/common/s3_file.rb +0 -16
  74. data/lib/neuron-client/model/common/zone.rb +0 -22
  75. data/lib/neuron-client/model/common/zone_calculations.rb +0 -41
  76. data/lib/neuron-client/model/membase/ad.rb +0 -49
  77. data/lib/neuron-client/model/membase/ad_zone.rb +0 -11
  78. data/lib/neuron-client/model/membase/blocked_referer.rb +0 -20
  79. data/lib/neuron-client/model/membase/blocked_user_agent.rb +0 -20
  80. data/lib/neuron-client/model/membase/geo_target.rb +0 -11
  81. data/lib/neuron-client/model/membase/pixel.rb +0 -22
  82. data/lib/neuron-client/model/membase/report.rb +0 -11
  83. data/lib/neuron-client/model/membase/s3_file.rb +0 -11
  84. data/lib/neuron-client/model/membase/zone.rb +0 -30
  85. data/lib/neuron-client/model/models.rb +0 -15
  86. data/spec/lib/model/admin/ad_spec.rb +0 -34
  87. data/spec/lib/model/admin/ad_zone_spec.rb +0 -19
  88. data/spec/lib/model/admin/base_spec.rb +0 -11
  89. data/spec/lib/model/admin/blocked_referer_spec.rb +0 -11
  90. data/spec/lib/model/admin/blocked_user_agent_spec.rb +0 -11
  91. data/spec/lib/model/admin/geo_target_spec.rb +0 -30
  92. data/spec/lib/model/admin/report_spec.rb +0 -21
  93. data/spec/lib/model/admin/s3_spec.rb +0 -11
  94. data/spec/lib/model/admin/zone_spec.rb +0 -21
  95. data/spec/lib/model/common/ad_calculations_spec.rb +0 -1151
  96. data/spec/lib/model/common/ad_spec.rb +0 -11
  97. data/spec/lib/model/common/ad_zone_spec.rb +0 -11
  98. data/spec/lib/model/common/base_spec.rb +0 -11
  99. data/spec/lib/model/common/blocked_referer_spec.rb +0 -11
  100. data/spec/lib/model/common/blocked_user_agent_spec.rb +0 -11
  101. data/spec/lib/model/common/geo_target_spec.rb +0 -11
  102. data/spec/lib/model/common/report_spec.rb +0 -11
  103. data/spec/lib/model/common/s3_spec.rb +0 -11
  104. data/spec/lib/model/common/zone_calculations_spec.rb +0 -54
  105. data/spec/lib/model/common/zone_spec.rb +0 -11
  106. data/spec/lib/model/membase/ad_spec.rb +0 -54
  107. data/spec/lib/model/membase/ad_zone_spec.rb +0 -11
  108. data/spec/lib/model/membase/base_spec.rb +0 -11
  109. data/spec/lib/model/membase/blocked_referer_spec.rb +0 -34
  110. data/spec/lib/model/membase/blocked_user_agent_spec.rb +0 -34
  111. data/spec/lib/model/membase/geo_target_spec.rb +0 -11
  112. data/spec/lib/model/membase/pixel_spec.rb +0 -34
  113. data/spec/lib/model/membase/report_spec.rb +0 -11
  114. data/spec/lib/model/membase/s3_spec.rb +0 -11
  115. data/spec/lib/model/membase/zone_spec.rb +0 -32
  116. data/spec/lib/old_spec.rb +0 -437
@@ -0,0 +1,129 @@
1
+ require 'json-schema'
2
+
3
+ module Neuron
4
+ module Schema
5
+ describe Report do
6
+ before(:each) do
7
+ @datetime = "2011-11-11T11:11:11Z"
8
+ @monkey_wrench = {"monkey_wrench" => {"id" => 42, "name" => "a"}}
9
+ @monkey_wrenches = [
10
+ {"monkey_wrench" => {"id" => 1, "name" => "a"}},
11
+ {"monkey_wrench" => {"id" => 2, "name" => "b"}},
12
+ {"monkey_wrench" => {"id" => 3, "name" => "c"}}
13
+ ]
14
+ end
15
+
16
+ def validate(data, opts={})
17
+ schema = opts[:against] || raise("You forgot to specify the schema!")
18
+ JSON::Validator.validate!(schema, data)
19
+ end
20
+
21
+ def invalidate(data, opts={})
22
+ schema = opts[:against] || raise("You forgot to specify the schema!")
23
+ JSON::Validator.validate(schema, data).should be_false
24
+ end
25
+
26
+ describe "index" do
27
+ it "should approve an example list of reports" do
28
+ validate(
29
+ [{"report" => {"id" => 42, "state" => "RUNNING", "template" => "delivery_metrics"}},
30
+ {"report" => {"id" => 82, "state" => "FAILED", "template" => "post_activities"}},
31
+ {"report" => {"id" => 246, "state" => "READY", "template" => "ad_events"}}
32
+ ],
33
+ :against => Report::SCHEMA.index)
34
+ end
35
+
36
+ it "should approve an empty list" do
37
+ validate([], :against => Report::SCHEMA.index)
38
+ end
39
+
40
+ it "should not approve an example report outside of a list" do
41
+ invalidate(
42
+ {"report" => {"id" => 246, "state" => "READY", "template" => "ad_events"}},
43
+ :against => Report::SCHEMA.index)
44
+ end
45
+
46
+ it "should not approve an example list of monkey wrenches" do
47
+ invalidate(@monkey_wrenches, :against => Report::SCHEMA.index)
48
+ end
49
+ end
50
+
51
+ describe "create" do
52
+ it "should approve an example report" do
53
+ validate({"report" => {
54
+ "template" => "ad_events",
55
+ "parameters" => {"start" => @datetime, "end" => @datetime}
56
+ }}, :against => Report::SCHEMA.create)
57
+ end
58
+
59
+ it "should not approve a report with missing information" do
60
+ invalidate({"report" => {
61
+ "template" => "ad_events",
62
+ "parameters" => {"start" => @datetime}
63
+ }}, :against => Report::SCHEMA.create)
64
+ end
65
+
66
+ it "should not approve a report with extra information" do
67
+ invalidate({"report" => {
68
+ "template" => "ad_events",
69
+ "parameters" => {"start" => @datetime, "end" => @datetime},
70
+ "state" => "WAITING" #extra
71
+ }}, :against => Report::SCHEMA.create)
72
+ end
73
+
74
+ it "should not approve a monkey wrench" do
75
+ invalidate(@monkey_wrench, :against => Report::SCHEMA.create)
76
+ end
77
+ end
78
+
79
+ describe "show" do
80
+ it "should approve an example report" do
81
+ validate({"report" => {
82
+ "template" => "ad_events",
83
+ "parameters" => {"start" => @datetime, "end" => @datetime},
84
+ "state" => "RUNNING",
85
+ "started_at" => @datetime,
86
+ "finished_at" => nil,
87
+ "accessed_at" => nil,
88
+ "created_at" => @datetime,
89
+ "updated_at" => @datetime,
90
+ "id" => 1
91
+ }}, :against => Report::SCHEMA.show)
92
+ end
93
+
94
+ it "should not approve a report with missing information" do
95
+ invalidate({"report" => {
96
+ "template" => "ad_events",
97
+ "parameters" => {"start" => @datetime, "end" => @datetime},
98
+ "state" => "RUNNING",
99
+ "started_at" => @datetime,
100
+ "finished_at" => nil,
101
+ "accessed_at" => nil,
102
+ # "created_at" => @datetime,
103
+ "updated_at" => @datetime,
104
+ "id" => 1
105
+ }}, :against => Report::SCHEMA.show)
106
+ end
107
+
108
+ it "should not approve a report with extra information" do
109
+ invalidate({"report" => {
110
+ "template" => "ad_events",
111
+ "parameters" => {"start" => @datetime, "end" => @datetime},
112
+ "state" => "RUNNING",
113
+ "started_at" => @datetime,
114
+ "finished_at" => nil,
115
+ "accessed_at" => nil,
116
+ "created_at" => @datetime,
117
+ "updated_at" => @datetime,
118
+ "id" => 1,
119
+ "name" => "extra"
120
+ }}, :against => Report::SCHEMA.show)
121
+ end
122
+
123
+ it "should not approve a monkey wrench" do
124
+ invalidate(@monkey_wrench, :against => Report::SCHEMA.show)
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,164 @@
1
+ require 'json-schema'
2
+
3
+ module Neuron
4
+ module Schema
5
+ describe S3File do
6
+ before(:each) do
7
+ @datetime = "2011-11-11T11:11:11Z"
8
+ @monkey_wrench = {"monkey_wrench" => {"id" => 42, "name" => "a"}}
9
+ @monkey_wrenches = [
10
+ {"monkey_wrench" => {"id" => 1, "name" => "a"}},
11
+ {"monkey_wrench" => {"id" => 2, "name" => "b"}},
12
+ {"monkey_wrench" => {"id" => 3, "name" => "c"}}
13
+ ]
14
+ end
15
+
16
+ def validate(data, opts={})
17
+ schema = opts[:against] || raise("You forgot to specify the schema!")
18
+ JSON::Validator.validate!(schema, data)
19
+ end
20
+
21
+ def invalidate(data, opts={})
22
+ schema = opts[:against] || raise("You forgot to specify the schema!")
23
+ JSON::Validator.validate(schema, data).should be_false
24
+ end
25
+
26
+ describe "index" do
27
+ it "should approve an example list of S3 files" do
28
+ validate(
29
+ [{"s3_file" => {"id" => 42, "bucket" => "abc", "filename" => "1.log", "filesize" => 123, "purpose" => "RAW_EVENT_LOG", "created_at" => @datetime, "updated_at" => @datetime}},
30
+ {"s3_file" => {"id" => 82, "bucket" => "abc", "filename" => "2.log", "filesize" => 123, "purpose" => "RAW_EVENT_LOG", "created_at" => @datetime, "updated_at" => @datetime}},
31
+ {"s3_file" => {"id" => 246, "bucket" => "abc", "filename" => "3.log", "filesize" => 123, "purpose" => "RAW_EVENT_LOG", "created_at" => @datetime, "updated_at" => @datetime}},
32
+ ],
33
+ :against => S3File::SCHEMA.index)
34
+ end
35
+
36
+ it "should approve an empty list" do
37
+ validate([], :against => S3File::SCHEMA.index)
38
+ end
39
+
40
+ it "should not approve an example S3 file outside of a list" do
41
+ invalidate(
42
+ {"s3_file" => {"id" => 42, "bucket" => "abc", "filename" => "1.log", "filesize" => 123, "purpose" => "RAW_EVENT_LOG", "created_at" => @datetime, "updated_at" => @datetime}},
43
+ :against => S3File::SCHEMA.index)
44
+ end
45
+
46
+ it "should not approve an example list of monkey wrenches" do
47
+ invalidate(@monkey_wrenches, :against => S3File::SCHEMA.index)
48
+ end
49
+ end
50
+
51
+ describe "create" do
52
+ it "should approve an example S3 file" do
53
+ validate({"s3_file" => {
54
+ "bucket" => "abc",
55
+ "filename" => "1.log",
56
+ "filesize" => nil,
57
+ "purpose" => "RAW_EVENT_LOG",
58
+ }}, :against => S3File::SCHEMA.create)
59
+ end
60
+
61
+ it "should not approve a S3 file with missing information" do
62
+ invalidate({"s3_file" => {
63
+ "bucket" => "abc",
64
+ "filename" => "1.log",
65
+ "purpose" => "RAW_EVENT_LOG",
66
+ }}, :against => S3File::SCHEMA.create)
67
+ end
68
+
69
+ it "should not approve a S3 file with extra information" do
70
+ invalidate({"s3_file" => {
71
+ "bucket" => "abc",
72
+ "filename" => "1.log",
73
+ "filesize" => nil,
74
+ "purpose" => "RAW_EVENT_LOG",
75
+ "name" => "extra"
76
+ }}, :against => S3File::SCHEMA.create)
77
+ end
78
+
79
+ it "should not approve a monkey wrench" do
80
+ invalidate(@monkey_wrench, :against => S3File::SCHEMA.create)
81
+ end
82
+ end
83
+
84
+ describe "show" do
85
+ it "should approve an example S3 file" do
86
+ validate({"s3_file" => {
87
+ "bucket" => "abc",
88
+ "filename" => "1.log",
89
+ "filesize" => nil,
90
+ "purpose" => "RAW_EVENT_LOG",
91
+ "created_at" => @datetime,
92
+ "updated_at" => @datetime,
93
+ "id" => 1
94
+ }}, :against => S3File::SCHEMA.show)
95
+ end
96
+
97
+ it "should not approve a S3 file with missing information" do
98
+ invalidate({"s3_file" => {
99
+ "bucket" => "abc",
100
+ "filename" => "1.log",
101
+ "purpose" => "RAW_EVENT_LOG",
102
+ "created_at" => @datetime,
103
+ "updated_at" => @datetime,
104
+ "id" => 1
105
+ }}, :against => S3File::SCHEMA.show)
106
+ end
107
+
108
+ it "should not approve a S3 file with extra information" do
109
+ invalidate({"s3_file" => {
110
+ "bucket" => "abc",
111
+ "filename" => "1.log",
112
+ "filesize" => nil,
113
+ "purpose" => "RAW_EVENT_LOG",
114
+ "created_at" => @datetime,
115
+ "updated_at" => @datetime,
116
+ "id" => 1,
117
+ "name" => "extra"
118
+ }}, :against => S3File::SCHEMA.show)
119
+ end
120
+
121
+ it "should not approve a monkey wrench" do
122
+ invalidate(@monkey_wrench, :against => S3File::SCHEMA.show)
123
+ end
124
+ end
125
+
126
+ describe "update" do
127
+ it "should approve an example S3 file" do
128
+ validate({"s3_file" => {
129
+ "bucket" => "abc",
130
+ "filename" => "1.log",
131
+ "filesize" => 1234,
132
+ "purpose" => "RAW_EVENT_LOG",
133
+ "id" => 1
134
+ }}, :against => S3File::SCHEMA.update)
135
+ end
136
+
137
+ it "should not approve a S3 file with missing id" do
138
+ invalidate({"s3_file" => {
139
+ "bucket" => "abc",
140
+ "filename" => "1.log",
141
+ "filesize" => 1234,
142
+ "purpose" => "RAW_EVENT_LOG",
143
+ #"id" => 1
144
+ }}, :against => S3File::SCHEMA.update)
145
+ end
146
+
147
+ it "should not approve a S3 file with extra information" do
148
+ invalidate({"s3_file" => {
149
+ "bucket" => "abc",
150
+ "filename" => "1.log",
151
+ "filesize" => nil,
152
+ "purpose" => "RAW_EVENT_LOG",
153
+ "id" => 1,
154
+ "name" => "extra"
155
+ }}, :against => S3File::SCHEMA.update)
156
+ end
157
+
158
+ it "should not approve a monkey wrench" do
159
+ invalidate(@monkey_wrench, :against => S3File::SCHEMA.update)
160
+ end
161
+ end
162
+ end
163
+ end
164
+ end
@@ -0,0 +1,243 @@
1
+ require 'json-schema'
2
+
3
+ module Neuron
4
+ module Schema
5
+ describe Zone do
6
+ before(:each) do
7
+ @datetime = "2011-11-11T11:11:11Z"
8
+ @monkey_wrench = {"monkey_wrench" => {"id" => 42, "name" => "a"}}
9
+ @monkey_wrenches = [
10
+ {"monkey_wrench" => {"id" => 1, "name" => "a"}},
11
+ {"monkey_wrench" => {"id" => 2, "name" => "b"}},
12
+ {"monkey_wrench" => {"id" => 3, "name" => "c"}}
13
+ ]
14
+ end
15
+
16
+ def validate(data, opts={})
17
+ schema = opts[:against] || raise("You forgot to specify the schema!")
18
+ JSON::Validator.validate!(schema, data)
19
+ end
20
+
21
+ def invalidate(data, opts={})
22
+ schema = opts[:against] || raise("You forgot to specify the schema!")
23
+ JSON::Validator.validate(schema, data).should be_false
24
+ end
25
+
26
+ describe "index" do
27
+ it "should approve an example list of zones" do
28
+ validate(
29
+ [{"zone" => {"id" => "abc123", "name" => nil}},
30
+ {"zone" => {"id" => "efg456", "name" => nil}},
31
+ {"zone" => {"id" => "hij789", "name" => nil}}
32
+ ],
33
+ :against => Zone::SCHEMA.index)
34
+ end
35
+
36
+ it "should approve an empty list" do
37
+ validate([], :against => Zone::SCHEMA.index)
38
+ end
39
+
40
+ it "should not approve an example zone outside of a list" do
41
+ invalidate(
42
+ {"zone" => {"id" => "abc123", "name" => "fred"}},
43
+ :against => Zone::SCHEMA.index)
44
+ end
45
+
46
+ it "should not approve an example list of monkey wrenches" do
47
+ invalidate(@monkey_wrenches, :against => Zone::SCHEMA.index)
48
+ end
49
+ end
50
+
51
+ describe "create" do
52
+ it "should approve an example redirect zone" do
53
+ validate({"zone" => {
54
+ "name" => "example_redirect_zone",
55
+ "response_type" => "Redirect",
56
+ "ad_links" => {"1" => {"weight" => 1.5, "priority" => 1},
57
+ "2" => {"weight" => 2.5, "priority" => 2}}
58
+ }}, :against => Zone::SCHEMA.create)
59
+ end
60
+
61
+ it "should approve an example iris zone" do
62
+ validate({"zone" => {
63
+ "name" => "example_iris_zone",
64
+ "response_type" => "Iris",
65
+ "ad_links" => {},
66
+ "expand" => "Yes",
67
+ "mute" => "No",
68
+ "autoplay" => "Yes",
69
+ "channel" => "drivel",
70
+ "template_slug" => "300x250",
71
+ "text_overlay" => "Yes",
72
+ "nami_feed_url" => "http://example.com/"
73
+ }}, :against => Zone::SCHEMA.create)
74
+ end
75
+
76
+ it "should approve an example vast zone" do
77
+ validate({"zone" => {
78
+ "name" => "example_vast_zone",
79
+ "response_type" => "Vast",
80
+ "ad_links" => {}
81
+ }}, :against => Zone::SCHEMA.create)
82
+ end
83
+
84
+ it "should not approve a zone with missing information" do
85
+ invalidate({"zone" => {
86
+ "name" => "example_redirect_zone",
87
+ #"response_type" => "Redirect",
88
+ "ad_links" => {"1" => {"weight" => 1.5, "priority" => 1},
89
+ "2" => {"weight" => 2.5, "priority" => 2}}
90
+ }}, :against => Zone::SCHEMA.create)
91
+ end
92
+
93
+ it "should not approve a zone with extra information" do
94
+ invalidate({"zone" => {
95
+ "name" => "example_redirect_zone",
96
+ "response_type" => "Redirect",
97
+ "ad_links" => {"1" => {"weight" => 1.5, "priority" => 1},
98
+ "2" => {"weight" => 2.5, "priority" => 2}},
99
+ "channel" => "extra"
100
+ }}, :against => Zone::SCHEMA.create)
101
+ end
102
+
103
+ it "should not approve a monkey wrench" do
104
+ invalidate(@monkey_wrench, :against => Zone::SCHEMA.create)
105
+ end
106
+ end
107
+
108
+ describe "show" do
109
+ it "should approve an example redirect zone" do
110
+ validate({"zone" => {
111
+ "name" => "example_redirect_zone",
112
+ "response_type" => "Redirect",
113
+ "ad_links" => {"1" => {"weight" => 1.5, "priority" => 1},
114
+ "2" => {"weight" => 2.5, "priority" => 2}},
115
+ "created_at" => @datetime,
116
+ "updated_at" => @datetime,
117
+ "id" => "abc123"
118
+ }}, :against => Zone::SCHEMA.show)
119
+ end
120
+
121
+ it "should approve an example iris zone" do
122
+ validate({"zone" => {
123
+ "name" => "example_iris_zone",
124
+ "response_type" => "Iris",
125
+ "ad_links" => {},
126
+ "expand" => "Yes",
127
+ "mute" => "No",
128
+ "autoplay" => "Yes",
129
+ "channel" => "drivel",
130
+ "template_slug" => "300x250",
131
+ "text_overlay" => "No",
132
+ "nami_feed_url" => nil,
133
+ "created_at" => @datetime,
134
+ "updated_at" => @datetime,
135
+ "id" => "abc123"
136
+ }}, :against => Zone::SCHEMA.show)
137
+ end
138
+
139
+ it "should approve an example vast zone" do
140
+ validate({"zone" => {
141
+ "name" => "example_vast_zone",
142
+ "response_type" => "Vast",
143
+ "ad_links" => {},
144
+ "created_at" => @datetime,
145
+ "updated_at" => @datetime,
146
+ "id" => "abc123"
147
+ }}, :against => Zone::SCHEMA.show)
148
+ end
149
+
150
+ it "should not approve a zone with missing information" do
151
+ invalidate({"zone" => {
152
+ #"name" => "example_redirect_zone",
153
+ "response_type" => "Redirect",
154
+ "ad_links" => {"1" => {"weight" => 1.5, "priority" => 1},
155
+ "2" => {"weight" => 2.5, "priority" => 2}},
156
+ "created_at" => @datetime,
157
+ "updated_at" => @datetime,
158
+ "id" => "abc123"
159
+ }}, :against => Zone::SCHEMA.show)
160
+ end
161
+
162
+ it "should not approve a zone with extra information" do
163
+ invalidate({"zone" => {
164
+ "name" => "example_redirect_zone",
165
+ "response_type" => "Redirect",
166
+ "ad_links" => {"1" => {"weight" => 1.5, "priority" => 1},
167
+ "2" => {"weight" => 2.5, "priority" => 2}},
168
+ "created_at" => @datetime,
169
+ "updated_at" => @datetime,
170
+ "id" => "abc123",
171
+ "channel" => "extra"
172
+ }}, :against => Zone::SCHEMA.show)
173
+ end
174
+
175
+ it "should not approve a monkey wrench" do
176
+ invalidate(@monkey_wrench, :against => Zone::SCHEMA.show)
177
+ end
178
+ end
179
+
180
+ describe "update" do
181
+ it "should approve an example redirect zone" do
182
+ validate({"zone" => {
183
+ "name" => "example_redirect_zone",
184
+ "response_type" => "Redirect",
185
+ "ad_links" => {"1" => {"weight" => 1.5, "priority" => 1},
186
+ "2" => {"weight" => 2.5, "priority" => 2}},
187
+ "id" => "abc123"
188
+ }}, :against => Zone::SCHEMA.update)
189
+ end
190
+
191
+ it "should approve an example iris zone" do
192
+ validate({"zone" => {
193
+ "name" => "example_iris_zone",
194
+ "response_type" => "Iris",
195
+ "ad_links" => {},
196
+ "expand" => "Yes",
197
+ "mute" => "No",
198
+ "autoplay" => "Yes",
199
+ "channel" => "drivel",
200
+ "text_overlay" => "No",
201
+ "nami_feed_url" => nil,
202
+ "template_slug" => "300x250",
203
+ "id" => "abc123"
204
+ }}, :against => Zone::SCHEMA.update)
205
+ end
206
+
207
+ it "should approve an example vast zone" do
208
+ validate({"zone" => {
209
+ "name" => "example vast zone",
210
+ "response_type" => "Vast",
211
+ "ad_links" => {},
212
+ "id" => "abc123"
213
+ }}, :against => Zone::SCHEMA.update)
214
+ end
215
+
216
+ it "should not approve a zone with missing id" do
217
+ invalidate({"zone" => {
218
+ "name" => "example_redirect_zone",
219
+ "response_type" => "Redirect",
220
+ "ad_links" => {"1" => {"weight" => 1.5, "priority" => 1},
221
+ "2" => {"weight" => 2.5, "priority" => 2}},
222
+ #"id" => "abc123"
223
+ }}, :against => Zone::SCHEMA.update)
224
+ end
225
+
226
+ it "should not approve a zone with extra information" do
227
+ invalidate({"zone" => {
228
+ "name" => "example_redirect_zone",
229
+ "response_type" => "Redirect",
230
+ "ad_links" => {"1" => {"weight" => 1.5, "priority" => 1},
231
+ "2" => {"weight" => 2.5, "priority" => 2}},
232
+ "id" => "abc123",
233
+ "channel" => "drivel"
234
+ }}, :against => Zone::SCHEMA.update)
235
+ end
236
+
237
+ it "should not approve a monkey wrench" do
238
+ invalidate(@monkey_wrench, :against => Zone::SCHEMA.update)
239
+ end
240
+ end
241
+ end
242
+ end
243
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  require 'simplecov'
2
2
  SimpleCov.start do
3
3
  add_filter "/spec/"
4
- add_group "Models", "lib"
4
+ add_group "Schema", "schema"
5
+ add_group "Models", "model"
5
6
  end
6
7
 
7
8
  require 'rubygems'