couch_scheduler 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -3,33 +3,142 @@ Feature: CouchPublish Integration
3
3
  I want to integrate CouchScheduler with CouchPublish
4
4
  So that I can query my database for published documents within a schedule
5
5
 
6
+ @focus
6
7
  Scenario: Query for published documents within a schedule
7
- Given an Article model that includes CouchPublish and CouchVisible
8
- When I create several published articles scheduled now and in the future
9
- And I create several unpublished articles scheduled now and in the future
10
- When I call "Article.by_schedule :published => true"
11
- Then I should receive the published documents scheduled now
12
- When I call "Article.by_schedule :unpublished => true"
13
- Then I should receive the unpublished documents scheduled now
14
- When I wait till the future
15
- And I call "Article.by_schedule :published => true"
16
- Then I should receive the published documents scheduled in the future
17
- When I call "Article.by_schedule :unpublished => true"
18
- Then I should receive the unpublished documents scheduled in the future
19
-
8
+ Given an Article model that includes CouchPublish and CouchVisible:
9
+ """
10
+ class Article < CouchRest::Model::Base
11
+ include CouchPublish
12
+ include CouchScheduler
13
+ end
14
+ """
15
+
16
+ When I create several published articles scheduled now and in the future:
17
+ """
18
+ @current_published_articles = []
19
+ @future_published_articles = []
20
+
21
+ 3.times { @current_published_articles << Article.create(:start => Time.now, :end => 1.day.from_now).tap {|a| a.publish! }}
22
+ 3.times { @future_published_articles << Article.create(:start => 1.day.from_now, :end => 2.days.from_now).tap {|a| a.publish! }}
23
+ """
24
+
25
+ And I create several unpublished articles scheduled now and in the future:
26
+ """
27
+ @current_unpublished_articles = []
28
+ @future_unpublished_articles = []
29
+
30
+ 3.times { @current_unpublished_articles << Article.create(:start => Time.now, :end => 1.day.from_now)}
31
+ 3.times { @future_unpublished_articles << Article.create(:start => 1.day.from_now, :end => 2.days.from_now)}
32
+ """
33
+
34
+ When I call "Article.map_within_schedule.published.get!":
35
+ """
36
+ @result = Article.map_within_schedule.published.get!
37
+ """
38
+
39
+ Then I should receive the published documents scheduled now:
40
+ """
41
+ @result.all? {|a| @current_published_articles.collect(&:id).include? a.id }.should be(true)
42
+ @result.length.should == @current_published_articles.length
43
+ """
44
+
45
+ When I call "Article.map_within_schedule.unpublished.get!":
46
+ """
47
+ @result = Article.map_within_schedule.unpublished.get!
48
+ """
49
+
50
+ Then I should receive the unpublished documents scheduled now:
51
+ """
52
+ @result.collect(&:id).sort.should == @current_unpublished_articles.collect(&:id).sort
53
+ @result.length.should == @current_unpublished_articles.length
54
+ """
55
+
56
+ When I wait a day:
57
+ """
58
+ Timecop.freeze 1.day.from_now
59
+ """
60
+
61
+ Then "Article.map_within_schedule.published.get!" should return the published documents I had scheduled in the future:
62
+ """
63
+ Article.map_within_schedule.published.get!.collect(&:id).sort.should == @future_published_articles.collect(&:id).sort
64
+ """
65
+
66
+ And "Article.map_within_schedule.unpublished.get!" should return the unpublished documents I had scheduled in the future:
67
+ """
68
+ Article.map_within_schedule.unpublished.get!.collect(&:id).sort.should == @future_unpublished_articles.collect(&:id).sort
69
+ """
70
+
71
+
20
72
  @focus
21
73
  Scenario: Count of published and unpublished documents within a schedule
22
- Given an Article model that includes CouchPublish and CouchVisible
23
- When I create 2 published articles scheduled now
24
- And I create 3 published articles schedule in the future
25
- And I create 4 unpublished articles scheduled now
26
- And I create 7 unpublished articles schedule in the future
27
- When I call "Article.count_schedule :published => true"
28
- Then I should receive 2
29
- When I call "Article.count_schedule :unpublished => true"
30
- Then I should receive 4
31
- When I wait till the future
32
- And I call "Article.count_schedule :published => true"
33
- Then I should receive 3
34
- When I call "Article.count_schedule :unpublished => true"
35
- Then I should receive 7
74
+
75
+ Given an Article model that includes CouchPublish and CouchVisible:
76
+ """
77
+ class Article < CouchRest::Model::Base
78
+ include CouchPublish
79
+ include CouchScheduler
80
+ end
81
+ """
82
+
83
+ When I create 2 published articles scheduled now:
84
+ """
85
+ @current_published_articles = []
86
+
87
+ 2.times { @current_published_articles << Article.create(:start => Time.now, :end => 1.day.from_now).tap {|a| a.publish! }}
88
+ """
89
+
90
+ When I create 3 published articles scheduled in the future:
91
+ """
92
+ @future_published_articles = []
93
+
94
+ 3.times { @future_published_articles << Article.create(:start => 1.day.from_now, :end => 2.days.from_now).tap {|a| a.publish! }}
95
+ """
96
+
97
+ And I create 4 unpublished articles scheduled now:
98
+ """
99
+ @current_unpublished_articles = []
100
+
101
+ 4.times { @current_unpublished_articles << Article.create(:start => Time.now, :end => 1.day.from_now)}
102
+ """
103
+
104
+ And I create 10 unpublished articles scheduled in the future:
105
+ """
106
+ @future_unpublished_articles = []
107
+
108
+ 10.times { @future_unpublished_articles << Article.create(:start => 1.day.from_now, :end => 2.days.from_now)}
109
+ """
110
+
111
+ When I call "Article.count_within_schedule.published.get!":
112
+ """
113
+ @result = Article.count_within_schedule.published.get!
114
+ """
115
+
116
+ Then I should receive the count of the published documents scheduled now:
117
+ """
118
+ @result.should == 2
119
+ """
120
+
121
+ When I call "Article.count_within_schedule.unpublished.get!":
122
+ """
123
+ @result = Article.count_within_schedule.unpublished.get!
124
+ """
125
+
126
+ Then I should receive the count of the unpublished documents scheduled now:
127
+ """
128
+ @result.should == 4
129
+ """
130
+
131
+ When I wait a day:
132
+ """
133
+ Timecop.freeze 1.day.from_now
134
+ """
135
+
136
+ Then "Article.count_within_schedule.published.get!" should return the count of the published documents I had scheduled in the future:
137
+ """
138
+ Article.count_within_schedule.published.get!.should == 3
139
+ """
140
+
141
+ And "Article.map_within_schedule.unpublished.get!" should return the count of the unpublished documents I had scheduled in the future:
142
+ """
143
+ Article.count_within_schedule.unpublished.get!.should == 10
144
+ """
@@ -4,42 +4,146 @@ Feature: CouchVisible and CouchPublish Integration
4
4
  So that I can query my database for shown, published documents within a schedule
5
5
 
6
6
  Scenario: Query for shown, published documents within a schedule
7
- Given a Slide model that includes CouchVisible, CouchPublish and CouchScheduler
8
- When I create several shown, published slides scheduled now and in the future
9
- And I create several shown, unpublished slides scheduled now and in the future
10
- And I create several hidden, published slides scheduled now and in the future
11
- And I create several hidden, unpublished slides scheduled now and in the future
12
- When I call "Slide.by_schedule :published => true, :shown => true"
13
- Then I should receive the shown, published documents scheduled now
14
- When I call "Slide.by_schedule :published => true, :hidden => true"
15
- Then I should receive the hidden, published documents scheduled now
16
- When I wait till the future
17
- And I call "Slide.by_schedule :published => true, :shown => true"
18
- Then I should receive the shown, published documents scheduled in the future
19
- When I call "Slide.by_schedule :published =>true, :hidden => true"
20
- Then I should receive the hidden, published documents scheduled in the future
21
-
22
- @focus
7
+ Given an Article model that includes CouchVisible, CouchPublish and CouchScheduler:
8
+ """
9
+ class Article < CouchRest::Model::Base
10
+ include CouchPublish
11
+ include CouchVisible
12
+ include CouchScheduler
13
+ end
14
+ """
15
+
16
+ When I create several shown, published articles scheduled now and in the future:
17
+ """
18
+ @current_published_shown_articles = []
19
+ @future_published_shown_articles = []
20
+
21
+ 3.times { @current_published_shown_articles << Article.create(:start => Time.now, :end => 1.day.from_now).tap {|a| a.publish!; a.show!; a.save }}
22
+ 3.times { @future_published_shown_articles << Article.create(:start => 1.day.from_now, :end => 2.days.from_now).tap {|a| a.publish!; a.show!; a.save}}
23
+ """
24
+
25
+ And I create several shown, unpublished articles scheduled now and in the future:
26
+ """
27
+ @current_unpublished_shown_articles = []
28
+ @future_unpublished_shown_articles = []
29
+
30
+ 3.times { @current_unpublished_shown_articles << Article.create(:start => Time.now, :end => 1.day.from_now).tap {|a| a.show!; a.save }}
31
+ 3.times { @future_unpublished_shown_articles << Article.create(:start => 1.day.from_now, :end => 2.days.from_now).tap {|a| a.show!; a.save}}
32
+ """
33
+
34
+ And I create several hidden, published articles scheduled now and in the future:
35
+ """
36
+ @current_published_hidden_articles = []
37
+ @future_published_hidden_articles = []
38
+
39
+ 3.times { @current_published_hidden_articles << Article.create(:start => Time.now, :end => 1.day.from_now).tap {|a| a.publish!}}
40
+ 3.times { @future_published_hidden_articles << Article.create(:start => 1.day.from_now, :end => 2.days.from_now).tap {|a| a.publish!}}
41
+ """
42
+
43
+
44
+ And I create several hidden, unpublished articles scheduled now and in the future:
45
+ """
46
+ @current_unpublished_hidden_articles = []
47
+ @future_unpublished_hidden_articles = []
48
+
49
+ 3.times { @current_unpublished_hidden_articles << Article.create(:start => Time.now, :end => 1.day.from_now)}
50
+ 3.times { @future_unpublished_hidden_articles << Article.create(:start => 1.day.from_now, :end => 2.days.from_now)}
51
+ """
52
+
53
+ Then "Article.map_within_schedule.published.shown.get!" should return the shown, published documents scheduled now:
54
+ """
55
+ Article.map_within_schedule.published.shown.get!.collect(&:id).sort.should == @current_published_shown_articles.collect(&:id).sort
56
+ """
57
+
58
+ And "Article.map_within_schedule.published.hidden.get!" should return the published, hidden documents scheduled now:
59
+ """
60
+ Article.map_within_schedule.published.hidden.get!.collect(&:id).sort.should == @current_published_hidden_articles.collect(&:id).sort
61
+ """
62
+
63
+ When I wait a day:
64
+ """
65
+ Timecop.freeze 1.day.from_now
66
+ """
67
+
68
+ Then "Article.by_schedule.published.shown.get!" should return the published, visible documents scheduled in the future:
69
+ """
70
+ Article.map_within_schedule.published.shown.get!.collect(&:id).sort.should == @future_published_shown_articles.collect(&:id).sort
71
+ """
72
+
73
+ And "Article.map_within_schedule.published.hidden.get!" should return the published, hidden documents scheduled now:
74
+ """
75
+ Article.map_within_schedule.published.hidden.get!.collect(&:id).sort.should == @future_published_hidden_articles.collect(&:id).sort
76
+ """
77
+
78
+
23
79
  Scenario: Count of shown and hidden documents within a schedule
24
- Given a Slide model that includes CouchVisible, CouchPublish and CouchScheduler
25
- When I create 2 shown, published slides scheduled now
26
- When I create 6 shown, unpublished slides scheduled now
27
- And I create 3 shown, published slides schedule in the future
28
- And I create 9 shown, unpublished slides schedule in the future
29
- And I create 4 hidden, published slides scheduled now
30
- And I create 12 hidden, unpublished slides scheduled now
31
- And I create 7 hidden, published slides schedule in the future
32
- And I create 21 hidden, unpublished slides schedule in the future
33
- When I call "Slide.count_schedule :published => true, :shown => true"
34
- Then I should receive 2
35
- When I call "Slide.count_schedule :published => true"
36
- Then I should receive 6
37
- When I call "Slide.count_schedule"
38
- Then I should receive 24
39
- When I call "Slide.count_schedule :published =>true, :hidden => true"
40
- Then I should receive 4
41
- When I wait till the future
42
- And I call "Slide.count_schedule :published => true, :shown => true"
43
- Then I should receive 3
44
- When I call "Slide.count_schedule :published =>true, :hidden => true"
45
- Then I should receive 7
80
+ Given an Article model that includes CouchVisible, CouchPublish and CouchScheduler:
81
+ """
82
+ class Article < CouchRest::Model::Base
83
+ include CouchPublish
84
+ include CouchVisible
85
+ include CouchScheduler
86
+ end
87
+ """
88
+
89
+ When I create 2 shown, published articles scheduled now and 10 in the future:
90
+ """
91
+ @current_published_shown_articles = []
92
+ @future_published_shown_articles = []
93
+
94
+ 2.times { @current_published_shown_articles << Article.create(:start => Time.now, :end => 1.day.from_now).tap {|a| a.publish!; a.show!; a.save }}
95
+ 10.times { @future_published_shown_articles << Article.create(:start => 1.day.from_now, :end => 2.days.from_now).tap {|a| a.publish!; a.show!; a.save}}
96
+ """
97
+
98
+ And I create 3 shown, unpublished articles scheduled now and 8 in the future:
99
+ """
100
+ @current_unpublished_shown_articles = []
101
+ @future_unpublished_shown_articles = []
102
+
103
+ 3.times { @current_unpublished_shown_articles << Article.create(:start => Time.now, :end => 1.day.from_now).tap {|a| a.show!; a.save }}
104
+ 8.times { @future_unpublished_shown_articles << Article.create(:start => 1.day.from_now, :end => 2.days.from_now).tap {|a| a.show!; a.save}}
105
+ """
106
+
107
+ And I create 5 hidden, published articles scheduled now and 14 in the future:
108
+ """
109
+ @current_published_hidden_articles = []
110
+ @future_published_hidden_articles = []
111
+
112
+ 5.times { @current_published_hidden_articles << Article.create(:start => Time.now, :end => 1.day.from_now).tap {|a| a.publish!}}
113
+ 14.times { @future_published_hidden_articles << Article.create(:start => 1.day.from_now, :end => 2.days.from_now).tap {|a| a.publish!}}
114
+ """
115
+
116
+
117
+ And I create 11 hidden, unpublished articles scheduled now and in the future:
118
+ """
119
+ @current_unpublished_hidden_articles = []
120
+ @future_unpublished_hidden_articles = []
121
+
122
+ 11.times { @current_unpublished_hidden_articles << Article.create(:start => Time.now, :end => 1.day.from_now)}
123
+ 11.times { @future_unpublished_hidden_articles << Article.create(:start => 1.day.from_now, :end => 2.days.from_now)}
124
+ """
125
+
126
+ Then "Article.count_within_schedule.published.shown.get!" should return 2:
127
+ """
128
+ Article.count_within_schedule.published.shown.get!.should == 2
129
+ """
130
+
131
+ And "Article.count_within_schedule.published.hidden.get!" should return 5:
132
+ """
133
+ Article.count_within_schedule.published.hidden.get!.should == 5
134
+ """
135
+
136
+ When I wait a day:
137
+ """
138
+ Timecop.freeze 1.day.from_now
139
+ """
140
+
141
+ Then "Article.count_within_schedule.published.shown.get!" should return 10:
142
+ """
143
+ Article.count_within_schedule.published.shown.get!.should == 10
144
+ """
145
+
146
+ And "Article.count_within_schedule.published.hidden.get!" should return 14:
147
+ """
148
+ Article.count_within_schedule.published.hidden.get!.should == 14
149
+ """
@@ -4,32 +4,140 @@ Feature: CouchVisible Integration
4
4
  So that I can query my database for shown documents within a schedule
5
5
 
6
6
  Scenario: Query for shown documents within a schedule
7
- Given an Post model that includes CouchVisible and CouchScheduler
8
- When I create several shown posts scheduled now and in the future
9
- And I create several hidden posts scheduled now and in the future
10
- When I call "Post.by_schedule :shown => true"
11
- Then I should receive the shown documents scheduled now
12
- When I call "Post.by_schedule :hidden => true"
13
- Then I should receive the hidden documents scheduled now
14
- When I wait till the future
15
- And I call "Post.by_schedule :shown => true"
16
- Then I should receive the shown documents scheduled in the future
17
- When I call "Post.by_schedule :hidden => true"
18
- Then I should receive the hidden documents scheduled in the future
19
-
7
+ Given an Article model that includes CouchVisible and CouchScheduler:
8
+ """
9
+ class Article < CouchRest::Model::Base
10
+ include CouchVisible
11
+ include CouchScheduler
12
+ end
13
+ """
14
+
15
+ When I create several shown articles scheduled now and in the future:
16
+ """
17
+ @current_shown_articles = []
18
+ @future_shown_articles = []
19
+
20
+ 3.times { @current_shown_articles << Article.create(:start => Time.now, :end => 1.day.from_now).tap {|a| a.show!; a.save }}
21
+ 3.times { @future_shown_articles << Article.create(:start => 1.day.from_now, :end => 2.days.from_now).tap {|a| a.show!; a.save }}
22
+ """
23
+
24
+ And I create several hidden articles scheduled now and in the future:
25
+ """
26
+ @current_hidden_articles = []
27
+ @future_hidden_articles = []
28
+
29
+ 3.times { @current_hidden_articles << Article.create(:start => Time.now, :end => 1.day.from_now)}
30
+ 3.times { @future_hidden_articles << Article.create(:start => 1.day.from_now, :end => 2.days.from_now)}
31
+ """
32
+
33
+ When I call "Article.map_within_schedule.shown.get!":
34
+ """
35
+ @result = Article.map_within_schedule.shown.get!
36
+ """
37
+
38
+ Then I should receive the shown documents scheduled now:
39
+ """
40
+ @result.all? {|a| @current_shown_articles.collect(&:id).include? a.id }.should be(true)
41
+ @result.length.should == @current_shown_articles.length
42
+ """
43
+
44
+ When I call "Article.map_within_schedule.hidden.get!":
45
+ """
46
+ @result = Article.map_within_schedule.hidden.get!
47
+ """
48
+
49
+ Then I should receive the hidden documents scheduled now:
50
+ """
51
+ @result.collect(&:id).sort.should == @current_hidden_articles.collect(&:id).sort
52
+ @result.length.should == @current_hidden_articles.length
53
+ """
54
+
55
+ When I wait a day:
56
+ """
57
+ Timecop.freeze 1.day.from_now
58
+ """
59
+
60
+ Then "Article.map_within_schedule.shown.get!" should return the shown documents I had scheduled in the future:
61
+ """
62
+ Article.map_within_schedule.shown.get!.collect(&:id).sort.should == @future_shown_articles.collect(&:id).sort
63
+ """
64
+
65
+ And "Article.map_within_schedule.hidden.get!" should return the hidden documents I had scheduled in the future:
66
+ """
67
+ Article.map_within_schedule.hidden.get!.collect(&:id).sort.should == @future_hidden_articles.collect(&:id).sort
68
+ """
69
+
70
+
20
71
  @focus
21
72
  Scenario: Count of shown and hidden documents within a schedule
22
- Given an Post model that includes CouchVisible and CouchScheduler
23
- When I create 2 shown posts scheduled now
24
- And I create 3 shown posts schedule in the future
25
- And I create 4 hidden posts scheduled now
26
- And I create 7 hidden posts schedule in the future
27
- When I call "Post.count_schedule :shown => true"
28
- Then I should receive 2
29
- When I call "Post.count_schedule :hidden => true"
30
- Then I should receive 4
31
- When I wait till the future
32
- And I call "Post.count_schedule :shown => true"
33
- Then I should receive 3
34
- When I call "Post.count_schedule :hidden => true"
35
- Then I should receive 7
73
+
74
+ Given an Article model that includes CouchScheduler and CouchVisible:
75
+ """
76
+ class Article < CouchRest::Model::Base
77
+ include CouchVisible
78
+ include CouchScheduler
79
+ end
80
+ """
81
+
82
+ When I create 2 shown articles scheduled now:
83
+ """
84
+ @current_shown_articles = []
85
+
86
+ 2.times { @current_shown_articles << Article.create(:start => Time.now, :end => 1.day.from_now).tap {|a| a.show!; a.save }}
87
+ """
88
+
89
+ When I create 3 shown articles scheduled in the future:
90
+ """
91
+ @future_shown_articles = []
92
+
93
+ 3.times { @future_shown_articles << Article.create(:start => 1.day.from_now, :end => 2.days.from_now).tap {|a| a.show!; a.save }}
94
+ """
95
+
96
+ And I create 4 hidden articles scheduled now:
97
+ """
98
+ @current_hidden_articles = []
99
+
100
+ 4.times { @current_hidden_articles << Article.create(:start => Time.now, :end => 1.day.from_now)}
101
+ """
102
+
103
+ And I create 10 hidden articles scheduled in the future:
104
+ """
105
+ @future_hidden_articles = []
106
+
107
+ 10.times { @future_hidden_articles << Article.create(:start => 1.day.from_now, :end => 2.days.from_now)}
108
+ """
109
+
110
+ When I call "Article.count_within_schedule.shown.get!":
111
+ """
112
+ @result = Article.count_within_schedule.shown.get!
113
+ """
114
+
115
+ Then I should receive the count of the shown documents scheduled now:
116
+ """
117
+ @result.should == 2
118
+ """
119
+
120
+ When I call "Article.count_within_schedule.hidden.get!":
121
+ """
122
+ @result = Article.count_within_schedule.hidden.get!
123
+ """
124
+
125
+ Then I should receive the count of the hidden documents scheduled now:
126
+ """
127
+ @result.should == 4
128
+ """
129
+
130
+ When I wait a day:
131
+ """
132
+ Timecop.freeze 1.day.from_now
133
+ """
134
+
135
+ Then "Article.count_within_schedule.shown.get!" should return the count of the shown documents I had scheduled in the future:
136
+ """
137
+ Article.count_within_schedule.shown.get!.should == 3
138
+ """
139
+
140
+ And "Article.map_within_schedule.hidden.get!" should return the count of the hidden documents I had scheduled in the future:
141
+ """
142
+ Article.count_within_schedule.hidden.get!.should == 10
143
+ """