admin_assistant 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. data/Rakefile +2 -2
  2. data/VERSION +1 -1
  3. data/admin_assistant.gemspec +2 -171
  4. metadata +4 -173
  5. data/rails_3_0/Gemfile +0 -12
  6. data/rails_3_0/Gemfile.lock +0 -100
  7. data/rails_3_0/README +0 -256
  8. data/rails_3_0/Rakefile +0 -7
  9. data/rails_3_0/app/controllers/admin/appointments2_controller.rb +0 -15
  10. data/rails_3_0/app/controllers/admin/appointments_controller.rb +0 -11
  11. data/rails_3_0/app/controllers/admin/blog_posts2_controller.rb +0 -138
  12. data/rails_3_0/app/controllers/admin/blog_posts3_controller.rb +0 -76
  13. data/rails_3_0/app/controllers/admin/blog_posts4_controller.rb +0 -21
  14. data/rails_3_0/app/controllers/admin/blog_posts5_controller.rb +0 -27
  15. data/rails_3_0/app/controllers/admin/blog_posts6_controller.rb +0 -10
  16. data/rails_3_0/app/controllers/admin/blog_posts_controller.rb +0 -9
  17. data/rails_3_0/app/controllers/admin/blog_posts_custom_new_and_edit_controller.rb +0 -15
  18. data/rails_3_0/app/controllers/admin/blog_posts_read_only_controller.rb +0 -19
  19. data/rails_3_0/app/controllers/admin/bookmarks_controller.rb +0 -11
  20. data/rails_3_0/app/controllers/admin/comments2_controller.rb +0 -14
  21. data/rails_3_0/app/controllers/admin/comments_controller.rb +0 -12
  22. data/rails_3_0/app/controllers/admin/images2_controller.rb +0 -11
  23. data/rails_3_0/app/controllers/admin/images_controller.rb +0 -6
  24. data/rails_3_0/app/controllers/admin/misconfigured1_controller.rb +0 -7
  25. data/rails_3_0/app/controllers/admin/not_migrated_yets_controller.rb +0 -9
  26. data/rails_3_0/app/controllers/admin/product_categories2_controller.rb +0 -7
  27. data/rails_3_0/app/controllers/admin/product_categories_controller.rb +0 -5
  28. data/rails_3_0/app/controllers/admin/television_airings_controller.rb +0 -5
  29. data/rails_3_0/app/controllers/admin/television_time_slots_controller.rb +0 -5
  30. data/rails_3_0/app/controllers/admin/users2_controller.rb +0 -10
  31. data/rails_3_0/app/controllers/admin/users_controller.rb +0 -48
  32. data/rails_3_0/app/controllers/application_controller.rb +0 -7
  33. data/rails_3_0/app/controllers/blog_posts_controller.rb +0 -5
  34. data/rails_3_0/app/helpers/admin/appointments_helper.rb +0 -2
  35. data/rails_3_0/app/helpers/admin/blog_posts2_helper.rb +0 -27
  36. data/rails_3_0/app/helpers/admin/blog_posts3_helper.rb +0 -2
  37. data/rails_3_0/app/helpers/admin/blog_posts4_helper.rb +0 -2
  38. data/rails_3_0/app/helpers/admin/blog_posts6_helper.rb +0 -13
  39. data/rails_3_0/app/helpers/admin/blog_posts_custom_new_and_edit_helper.rb +0 -29
  40. data/rails_3_0/app/helpers/admin/blog_posts_helper.rb +0 -2
  41. data/rails_3_0/app/helpers/admin/blog_posts_read_only_helper.rb +0 -2
  42. data/rails_3_0/app/helpers/admin/bookmarks_helper.rb +0 -2
  43. data/rails_3_0/app/helpers/admin/comments2_helper.rb +0 -2
  44. data/rails_3_0/app/helpers/admin/comments_helper.rb +0 -2
  45. data/rails_3_0/app/helpers/admin/images2_helper.rb +0 -8
  46. data/rails_3_0/app/helpers/admin/images_helper.rb +0 -2
  47. data/rails_3_0/app/helpers/admin/misconfigured1_helper.rb +0 -2
  48. data/rails_3_0/app/helpers/admin/not_migrated_yets_helper.rb +0 -2
  49. data/rails_3_0/app/helpers/admin/product_categories2_helper.rb +0 -2
  50. data/rails_3_0/app/helpers/admin/product_categories_helper.rb +0 -2
  51. data/rails_3_0/app/helpers/admin/television_airings_helper.rb +0 -2
  52. data/rails_3_0/app/helpers/admin/television_time_slots_helper.rb +0 -2
  53. data/rails_3_0/app/helpers/admin/users2_helper.rb +0 -2
  54. data/rails_3_0/app/helpers/admin/users_helper.rb +0 -13
  55. data/rails_3_0/app/helpers/application_helper.rb +0 -2
  56. data/rails_3_0/app/models/appointment.rb +0 -5
  57. data/rails_3_0/app/models/blog_post.rb +0 -14
  58. data/rails_3_0/app/models/blog_post_tag.rb +0 -6
  59. data/rails_3_0/app/models/bookmark.rb +0 -6
  60. data/rails_3_0/app/models/comment.rb +0 -4
  61. data/rails_3_0/app/models/image.rb +0 -3
  62. data/rails_3_0/app/models/not_migrated_yet.rb +0 -2
  63. data/rails_3_0/app/models/product.rb +0 -5
  64. data/rails_3_0/app/models/product_category.rb +0 -9
  65. data/rails_3_0/app/models/tag.rb +0 -4
  66. data/rails_3_0/app/models/television_airing.rb +0 -3
  67. data/rails_3_0/app/models/television_time_slot.rb +0 -11
  68. data/rails_3_0/app/models/user.rb +0 -11
  69. data/rails_3_0/app/views/admin/appointments/_subject_input.html.erb +0 -2
  70. data/rails_3_0/app/views/admin/appointments2/_time_input.html.erb +0 -31
  71. data/rails_3_0/app/views/admin/blog_posts2/_after_form.html.erb +0 -5
  72. data/rails_3_0/app/views/admin/blog_posts2/_after_index.html.erb +0 -1
  73. data/rails_3_0/app/views/admin/blog_posts2/_after_tags_input.html.erb +0 -16
  74. data/rails_3_0/app/views/admin/blog_posts2/_before_index.html.erb +0 -2
  75. data/rails_3_0/app/views/admin/blog_posts5/_after_index_header.html.erb +0 -8
  76. data/rails_3_0/app/views/admin/blog_posts_read_only/_body_for_show.html.erb +0 -1
  77. data/rails_3_0/app/views/layouts/admin.html.erb +0 -32
  78. data/rails_3_0/app/views/layouts/application.html.erb +0 -14
  79. data/rails_3_0/config.ru +0 -4
  80. data/rails_3_0/config/application.rb +0 -42
  81. data/rails_3_0/config/boot.rb +0 -6
  82. data/rails_3_0/config/database.yml +0 -22
  83. data/rails_3_0/config/environment.rb +0 -5
  84. data/rails_3_0/config/environments/development.rb +0 -25
  85. data/rails_3_0/config/environments/production.rb +0 -49
  86. data/rails_3_0/config/environments/test.rb +0 -35
  87. data/rails_3_0/config/initializers/backtrace_silencers.rb +0 -7
  88. data/rails_3_0/config/initializers/inflections.rb +0 -10
  89. data/rails_3_0/config/initializers/mime_types.rb +0 -5
  90. data/rails_3_0/config/initializers/secret_token.rb +0 -7
  91. data/rails_3_0/config/initializers/session_store.rb +0 -8
  92. data/rails_3_0/config/locales/en.yml +0 -5
  93. data/rails_3_0/config/routes.rb +0 -8
  94. data/rails_3_0/db/migrate/20090213215514_create_blog_posts.rb +0 -12
  95. data/rails_3_0/db/migrate/20090217225542_add_body_to_blog_posts.rb +0 -9
  96. data/rails_3_0/db/migrate/20090221220917_create_tags.rb +0 -13
  97. data/rails_3_0/db/migrate/20090221220947_create_blog_post_tags.rb +0 -14
  98. data/rails_3_0/db/migrate/20090222162204_add_textile_to_blog_posts.rb +0 -9
  99. data/rails_3_0/db/migrate/20090222163231_add_published_at_to_blog_posts.rb +0 -9
  100. data/rails_3_0/db/migrate/20090301191722_create_images.rb +0 -16
  101. data/rails_3_0/db/migrate/20090305165345_create_accounts.rb +0 -14
  102. data/rails_3_0/db/migrate/20090307225027_rename_accounts_to_users.rb +0 -9
  103. data/rails_3_0/db/migrate/20090307225750_add_user_id_to_blog_posts.rb +0 -9
  104. data/rails_3_0/db/migrate/20090309185114_change_blog_posts_textile.rb +0 -9
  105. data/rails_3_0/db/migrate/20090309193635_create_products.rb +0 -14
  106. data/rails_3_0/db/migrate/20090309203056_create_comments.rb +0 -15
  107. data/rails_3_0/db/migrate/20090323005947_create_file_column_images.rb +0 -12
  108. data/rails_3_0/db/migrate/20090326160049_add_birthday_to_users.rb +0 -9
  109. data/rails_3_0/db/migrate/20090326223606_add_state_to_users.rb +0 -9
  110. data/rails_3_0/db/migrate/20090503134004_add_file_column_image_to_products.rb +0 -9
  111. data/rails_3_0/db/migrate/20090617173651_create_bookmarks.rb +0 -15
  112. data/rails_3_0/db/migrate/20090624165355_add_tags_string_to_blog_post.rb +0 -9
  113. data/rails_3_0/db/migrate/20090625144313_add_avatar_fields_to_user.rb +0 -11
  114. data/rails_3_0/db/migrate/20090629202956_add_merged_into_to_blog_posts.rb +0 -9
  115. data/rails_3_0/db/migrate/20090701171857_add_force_textile_to_users.rb +0 -9
  116. data/rails_3_0/db/migrate/20090704163647_add_deleted_at_to_products.rb +0 -9
  117. data/rails_3_0/db/migrate/20090704173800_add_sale_fields_to_products.rb +0 -13
  118. data/rails_3_0/db/migrate/20090714024501_create_product_categories.rb +0 -15
  119. data/rails_3_0/db/migrate/20090819162835_add_admin_level_to_users.rb +0 -9
  120. data/rails_3_0/db/migrate/20091115134559_add_first_and_last_names_to_users.rb +0 -11
  121. data/rails_3_0/db/migrate/20091221011256_add_position_to_product_categories.rb +0 -9
  122. data/rails_3_0/db/migrate/20091222160814_create_appointments.rb +0 -14
  123. data/rails_3_0/db/migrate/20091227224547_add_user_id_to_appointments.rb +0 -9
  124. data/rails_3_0/db/migrate/20100214213359_create_television_time_slots.rb +0 -13
  125. data/rails_3_0/db/migrate/20100214213451_create_television_airings.rb +0 -15
  126. data/rails_3_0/db/migrate/20110426215702_remove_avatar_fields_from_users.rb +0 -11
  127. data/rails_3_0/db/seeds.rb +0 -7
  128. data/rails_3_0/doc/README_FOR_APP +0 -2
  129. data/rails_3_0/public/404.html +0 -26
  130. data/rails_3_0/public/422.html +0 -26
  131. data/rails_3_0/public/500.html +0 -26
  132. data/rails_3_0/public/favicon.ico +0 -0
  133. data/rails_3_0/public/images/rails.png +0 -0
  134. data/rails_3_0/public/index.html +0 -239
  135. data/rails_3_0/public/javascripts/application.js +0 -2
  136. data/rails_3_0/public/javascripts/jquery-1.4.4.min.js +0 -167
  137. data/rails_3_0/public/javascripts/rails.js +0 -191
  138. data/rails_3_0/public/robots.txt +0 -5
  139. data/rails_3_0/public/stylesheets/admin.css +0 -3
  140. data/rails_3_0/public/stylesheets/scaffold.css +0 -54
  141. data/rails_3_0/script/rails +0 -6
  142. data/rails_3_0/test/data/ruby_throated.jpg +0 -0
  143. data/rails_3_0/test/data/tweenbot.jpg +0 -0
  144. data/rails_3_0/test/fixtures/placeholder.txt +0 -0
  145. data/rails_3_0/test/integration/admin/appointments2_integration_test.rb +0 -79
  146. data/rails_3_0/test/integration/admin/appointments_integration_test.rb +0 -367
  147. data/rails_3_0/test/integration/admin/blog_posts2_integration_test.rb +0 -789
  148. data/rails_3_0/test/integration/admin/blog_posts3_integration_test.rb +0 -418
  149. data/rails_3_0/test/integration/admin/blog_posts4_integration_test.rb +0 -189
  150. data/rails_3_0/test/integration/admin/blog_posts5_integration_test.rb +0 -75
  151. data/rails_3_0/test/integration/admin/blog_posts6_integration_test.rb +0 -39
  152. data/rails_3_0/test/integration/admin/blog_posts_custom_new_and_edit_integration_test.rb +0 -89
  153. data/rails_3_0/test/integration/admin/blog_posts_integration_test.rb +0 -776
  154. data/rails_3_0/test/integration/admin/blog_posts_read_only_integration_test.rb +0 -69
  155. data/rails_3_0/test/integration/admin/bookmarks_integration_test.rb +0 -445
  156. data/rails_3_0/test/integration/admin/comments2_integration_test.rb +0 -52
  157. data/rails_3_0/test/integration/admin/comments_integration_test.rb +0 -50
  158. data/rails_3_0/test/integration/admin/images2_integration_test.rb +0 -33
  159. data/rails_3_0/test/integration/admin/images_integration_test.rb +0 -79
  160. data/rails_3_0/test/integration/admin/misconfigured1_integration_test.rb +0 -21
  161. data/rails_3_0/test/integration/admin/product_categories2_integration_test.rb +0 -179
  162. data/rails_3_0/test/integration/admin/product_categories_integration_test.rb +0 -12
  163. data/rails_3_0/test/integration/admin/television_airings_integration_test.rb +0 -25
  164. data/rails_3_0/test/integration/admin/users2_integration_test.rb +0 -48
  165. data/rails_3_0/test/integration/admin/users_integration_test.rb +0 -182
  166. data/rails_3_0/test/integration/blog_posts_integration_test.rb +0 -10
  167. data/rails_3_0/test/performance/browsing_test.rb +0 -9
  168. data/rails_3_0/test/test_helper.rb +0 -138
  169. data/rails_3_1/Gemfile +0 -12
  170. data/rails_3_1/Gemfile.lock +0 -116
  171. data/rails_3_1/README +0 -256
  172. data/rails_3_1/Rakefile +0 -7
  173. data/rails_3_1/config.ru +0 -4
@@ -1,418 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
2
-
3
- class Admin::BlogPosts3IntegrationTest < ActionController::IntegrationTest
4
- def setup
5
- User.destroy_all
6
- @user = User.create! :username => 'soren', :password => 'password'
7
- end
8
-
9
- def test_create_with_no_title
10
- @orig_blog_post_count = BlogPost.count
11
- post "/admin/blog_posts3", :blog_post => {:user_id => @user.id}
12
-
13
- # should redirect to the index
14
- assert_redirected_to(:action => 'index')
15
-
16
- # should create a new blog post with the title pre-filled as (draft)
17
- assert_equal(@orig_blog_post_count + 1, BlogPost.count)
18
- blog_post = BlogPost.last
19
- assert_equal('(draft)', blog_post.title)
20
- end
21
-
22
- def test_edit
23
- @blog_post = BlogPost.create! :title => random_word, :user => @user
24
- get "/admin/blog_posts3/#{@blog_post.id}/edit"
25
-
26
- # should have a body field
27
- assert_select('textarea[name=?]', 'blog_post[body]')
28
-
29
- # should not include textile
30
- assert_no_match(/textile/, response.body)
31
- end
32
-
33
- def test_index_with_no_blog_posts
34
- BlogPost.destroy_all
35
- get "/admin/blog_posts3"
36
- assert_response :success
37
-
38
- # should use the activescaffold-themed CSS
39
- assert_select(
40
- 'link[href^=/stylesheets/admin_assistant/activescaffold.css]'
41
- )
42
-
43
- # should say 'Posts'
44
- assert_select('h2', :text => 'Posts')
45
- end
46
-
47
- def test_index_with_one_unpublished_blog_post
48
- BlogPost.destroy_all
49
- @blog_post = BlogPost.create!(
50
- :title => "unpublished blog post", :user => @user,
51
- :published_at => nil
52
- )
53
- $cache.flush
54
- get "/admin/blog_posts3"
55
-
56
- # should show the blog post
57
- assert_match(/unpublished blog post/, response.body)
58
-
59
- # should show 'No' from having called BlogPost#published?
60
- assert_select("tr[id=blog_post_#{@blog_post.id}]") do
61
- assert_select "td", :text => 'No'
62
- end
63
-
64
- # should not have a comparator for the ID search field
65
- assert_select('form[id=search_form][method=get]') do
66
- assert_select("select[name=?]", "search[id(comparator)]", false)
67
- end
68
-
69
- # should have a blank checkbox for the body search field
70
- assert_select('form[id=search_form][method=get]') do
71
- assert_select("input[type=checkbox][name=?]", "search[body(blank)]")
72
- end
73
-
74
- # should render extra action links in order
75
- assert_match(/Short title.*Blank body/m, response.body)
76
-
77
- # should have a trinary select for the has_short_title search field
78
- assert_select('form[id=search_form][method=get]') do
79
- assert_select('select[name=?]', 'search[has_short_title]') do
80
- assert_select("option[value='']", :text => '')
81
- assert_select("option[value='true']", :text => 'Yes')
82
- assert_select("option[value='false']", :text => 'No')
83
- end
84
- end
85
-
86
- # should show a search form with specific fields
87
- assert_select(
88
- 'form[id=search_form][method=get]', :text => /Title/
89
- ) do
90
- assert_select('input[name=?]', 'search[title]')
91
- assert_select('input[name=?]', 'search[body]')
92
- assert_select('select[name=?]', 'search[textile]') do
93
- assert_select("option[value='']", :text => '')
94
- assert_select("option[value='true']", :text => 'true')
95
- assert_select("option[value='false']", :text => 'false')
96
- end
97
- assert_select('label', :text => 'User')
98
- assert_select('input[name=?]', 'search[user]')
99
- end
100
-
101
- # should set the count in memcache
102
- key =
103
- "AdminAssistant::Admin::BlogPosts3Controller_count_published_at_is_null_"
104
- assert_equal(1, $cache.read(key))
105
- assert_in_delta(12.hours, $cache.expires_in(key), 5.seconds)
106
-
107
- # should not make the textile field an Ajax toggle
108
- toggle_div_id = "blog_post_#{@blog_post.id}_textile"
109
- assert_no_match(%r|new Ajax.Updater\('#{toggle_div_id}'|, response.body)
110
- end
111
-
112
- def test_index_with_a_published_blog_post
113
- $cache.flush
114
- BlogPost.destroy_all
115
- BlogPost.create!(
116
- :title => "published blog post", :user => @user,
117
- :published_at => Time.now.utc
118
- )
119
- get "/admin/blog_posts3"
120
-
121
- # should not show the blog post
122
- assert_no_match(/published blog post/, response.body)
123
- assert_match(/No posts found/, response.body)
124
- end
125
-
126
- def test_index_when_searching_by_user
127
- User.destroy_all
128
- tiffany = User.create!(:username => 'tiffany')
129
- BlogPost.create! :title => "By Tiffany", :user => tiffany
130
- BlogPost.create!(
131
- :title => "Already published", :user => tiffany,
132
- :published_at => Time.now
133
- )
134
- bill = User.create! :username => 'bill', :password => 'parsimony'
135
- BlogPost.create! :title => "By Bill", :user => bill
136
- brooklyn_steve = User.create!(
137
- :username => 'brooklyn_steve', :state => 'NY'
138
- )
139
- BlogPost.create! :title => "By Brooklyn Steve", :user => brooklyn_steve
140
- sadie = User.create!(
141
- :username => 'Sadie', :password => 'sadie', :state => 'KY'
142
- )
143
- BlogPost.create! :title => "By Sadie", :user => sadie
144
- get(
145
- "/admin/blog_posts3",
146
- :search => {
147
- :body => "", :textile => "", :id => "", :user => 'ny',
148
- :has_short_title => ''
149
- }
150
- )
151
- assert_response :success
152
-
153
- # should match the string to the username
154
- assert_match(/By Tiffany/, response.body)
155
-
156
- # should match the string to the password
157
- assert_match(/By Bill/, response.body)
158
-
159
- # should match the string to the state
160
- assert_match(/By Brooklyn Steve/, response.body)
161
-
162
- # should skip blog posts that don't match anything on the user
163
- assert_no_match(/By Sadie/, response.body)
164
-
165
- # should skip blog posts that have already been published
166
- assert_no_match(/Already published/, response.body)
167
- end
168
-
169
- def test_index_with_blog_posts_from_two_different_users
170
- aardvark_man = User.create!(:username => 'aardvark_man')
171
- BlogPost.create! :title => 'AARDVARKS!!!!!1', :user => aardvark_man
172
- ziggurat = User.create!(:username => 'zigguratz')
173
- BlogPost.create! :title => "Wanna go climbing?", :user => ziggurat
174
- get "/admin/blog_posts3"
175
- assert_response :success
176
-
177
- # should sort by username
178
- assert_match(%r|AARDVARKS!!!!!1.*Wanna go climbing|m, response.body)
179
- end
180
-
181
- def test_index_when_searching_for_a_blank_body
182
- BlogPost.destroy_all
183
- @nil_body_post = BlogPost.create!(
184
- :title => "nil", :user => @user, :body => nil
185
- )
186
- @empty_string_body_post = BlogPost.create!(
187
- :title => "empty string", :user => @user, :body => ''
188
- )
189
- @non_blank_body_post = BlogPost.create!(
190
- :title => "non-blank", :user => @user, :body => 'foo'
191
- )
192
- get(
193
- "/admin/blog_posts3",
194
- :search => {
195
- "body(blank)" => '1', :user => '', :body => '', :title => '',
196
- :textile => '', :id => '', '(all_or_any)' => 'all',
197
- :has_short_title => ''
198
- }
199
- )
200
-
201
- # should retrieve a blog post with a nil body
202
- assert_select("tr[id=?]", "blog_post_#{@nil_body_post.id}")
203
-
204
- # should retrieve a blog post with a space-only string body
205
- assert_select(
206
- "tr[id=?]", "blog_post_#{@empty_string_body_post.id}"
207
- )
208
-
209
- # should not retrieve a blog post with a non-blank body
210
- assert_select(
211
- "tr[id=?]", "blog_post_#{@non_blank_body_post.id}", false
212
- )
213
-
214
- # should have a checked blank checkbox for the body search field
215
- assert_select('form[id=search_form][method=get]') do
216
- assert_select(
217
- "input[type=checkbox][checked=checked][name=?]",
218
- "search[body(blank)]"
219
- )
220
- end
221
- end
222
-
223
- def test_index_when_searching_for_short_title_blog_posts
224
- BlogPost.destroy_all
225
- @bp1 = BlogPost.create!(
226
- :title => 'short', :body => 'foobar', :user => @user
227
- )
228
- @bp2 = BlogPost.create!(
229
- :title => "longer title", :body => 'foobar', :user => @user
230
- )
231
- get(
232
- "/admin/blog_posts3",
233
- :search => {
234
- :body => "", "body(blank)" => '0', :textile => "", :id => "",
235
- :user => '', :has_short_title => 'true'
236
- }
237
- )
238
-
239
- # should return a short-titled blog post
240
- assert_select('td', :text => 'short')
241
-
242
- # should not return a longer-title blog post
243
- assert_no_match(%r|<td[^>]*>longer title</td>|, response.body)
244
-
245
- # should pre-select 'true' in the has_short_title search field
246
- assert_select('form[id=search_form][method=get]') do
247
- assert_select('select[name=?]', 'search[has_short_title]') do
248
- assert_select("option[value='']", :text => '')
249
- assert_select("option[value='true'][selected=selected]", :text => 'Yes')
250
- assert_select("option[value='false']", :text => 'No')
251
- end
252
- end
253
- end
254
-
255
- def test_index_when_searching_for_long_titled_blog_posts
256
- BlogPost.destroy_all
257
- @bp1 = BlogPost.create!(
258
- :title => 'short', :body => 'foobar', :user => @user
259
- )
260
- @bp2 = BlogPost.create!(
261
- :title => "longer title", :body => 'foobar', :user => @user
262
- )
263
- get(
264
- "/admin/blog_posts3",
265
- :search => {
266
- :body => "", "body(blank)" => '0', :textile => "", :id => "",
267
- :user => '', :has_short_title => 'false'
268
- }
269
- )
270
-
271
- # should not return a short-titled blog post
272
- assert_no_match(%r|<td[^>]*>short</td>|, response.body)
273
-
274
- # should return a longer-title blog post
275
- assert_select('td', :text => 'longer title')
276
-
277
- # should pre-select 'false' in the has_short_title search field
278
- assert_select('form[id=search_form][method=get]') do
279
- assert_select('select[name=?]', 'search[has_short_title]') do
280
- assert_select("option[value='']", :text => '')
281
- assert_select("option[value='true']", :text => 'Yes')
282
- assert_select("option[value='false'][selected=selected]", :text => 'No')
283
- end
284
- end
285
- end
286
-
287
- def test_index_when_searching_for_blog_posts_of_any_title_length
288
- BlogPost.destroy_all
289
- @bp1 = BlogPost.create!(
290
- :title => 'short', :body => 'foobar', :user => @user
291
- )
292
- @bp2 = BlogPost.create!(
293
- :title => "longer title", :body => 'foobar', :user => @user
294
- )
295
- get(
296
- "/admin/blog_posts3",
297
- :search => {
298
- :body => 'foobar', "body(blank)" => '0', :textile => "", :id => "",
299
- :user => '', :has_short_title => ''
300
- }
301
- )
302
-
303
- # should return a short-titled blog post
304
- assert_select('td', :text => 'short')
305
-
306
- # should return a longer-title blog post
307
- assert_select('td', :text => 'longer title')
308
- end
309
-
310
- def test_index_when_searching_by_id
311
- BlogPost.destroy_all
312
- @blog_post1 = BlogPost.create! :title => random_word, :user => @user
313
- blog_post2 = BlogPost.create! :title => random_word, :user => @user
314
- BlogPost.update_all(
315
- "id = #{@blog_post1.id * 10}", "id = #{blog_post2.id}"
316
- )
317
- @blog_post2 = BlogPost.find(@blog_post1.id * 10)
318
- get(
319
- "/admin/blog_posts3",
320
- :search => {
321
- :body => '', "body(blank)" => '0', :textile => "",
322
- :id => @blog_post1.id.to_s, :user => '', :has_short_title => ''
323
- }
324
- )
325
-
326
- # should match the record with that ID
327
- assert_select("tr[id=?]", "blog_post_#{@blog_post1.id}")
328
-
329
- # should not match a record with an ID that has the ID as a substring
330
- assert_select("tr[id=?]", "blog_post_#{@blog_post2.id}", false)
331
- end
332
-
333
- def test_index_when_the_blank_body_count_has_been_cached_in_memcache_but_the_request_is_looking_for_the_default_index
334
- $cache.flush
335
- another_key =
336
- "AdminAssistant::Admin::BlogPosts3Controller_count__body_is_null_or_body______"
337
- $cache.write another_key, 1_000_000, :expires_in => 12.hours
338
- get "/admin/blog_posts3"
339
-
340
- # should not read a value from memcache
341
- assert_no_match(/1000000 posts found/, response.body)
342
-
343
- # should set the count in memcache
344
- key =
345
- "AdminAssistant::Admin::BlogPosts3Controller_count_published_at_is_null_"
346
- assert $cache.read(key)
347
- assert_in_delta(12.hours, $cache.expires_in(key), 5.seconds)
348
- end
349
-
350
- def test_index_when_the_count_has_been_cached_in_memcache
351
- BlogPost.create!(:title => "title", :user => @user)
352
- key =
353
- "AdminAssistant::Admin::BlogPosts3Controller_count_published_at_is_null_"
354
- $cache.write key, 1_000_000, :expires_in => 12.hours
355
- $cache.raise_on_write
356
- get "/admin/blog_posts3"
357
-
358
- # should read memcache and not hit the database
359
- assert_match(/1000000 posts found/, response.body)
360
- end
361
-
362
- def test_index_with_more_than_one_pages_worth_of_unpublished_blog_posts
363
- $cache.flush
364
- BlogPost.destroy_all
365
- 1.upto(26) do |i|
366
- BlogPost.create!(
367
- :title => "unpublished blog post #{i}", :user => @user,
368
- :published_at => nil
369
- )
370
- end
371
- @unpub_count = BlogPost.count "published_at is null"
372
- $cache.flush
373
- get "/admin/blog_posts3"
374
-
375
- # should cache the total number of entries, not the entries on just this page
376
- key =
377
- "AdminAssistant::Admin::BlogPosts3Controller_count_published_at_is_null_"
378
- assert_equal(@unpub_count, $cache.read(key))
379
- assert_in_delta(12.hours, $cache.expires_in(key), 5.seconds)
380
- end
381
-
382
- def test_new
383
- @request_time = Time.now.utc
384
- get "/admin/blog_posts3/new"
385
-
386
- # should not have a body field
387
- assert_select('textarea[name=?]', 'blog_post[body]', false)
388
-
389
- # should have a published_at select that starts in the year 2009
390
- name = 'blog_post[published_at(1i)]'
391
- assert_select('select[name=?]', name) do
392
- assert_select "option[value='2009']"
393
- assert_select "option[value='2010']"
394
- assert_select "option[value='2008']", false
395
- end
396
-
397
- # should have a published_at select that is set to now
398
- name = 'blog_post[published_at(3i)]'
399
- assert_select('select[name=?]', name) do
400
- assert_select "option[value=?][selected=selected]", @request_time.day
401
- end
402
-
403
- # should not show a nullify link for published_at
404
- assert_no_match(%r|<a [^>]*>Set "published at" to nil</a>|, response.body)
405
-
406
- # should say 'New post'
407
- assert_select('h2', :text => 'New post')
408
- end
409
-
410
- def test_show
411
- @blog_post = BlogPost.create! :title => "title", :user => @user
412
- get "/admin/blog_posts3/#{@blog_post.id}"
413
- assert_response :success
414
-
415
- # should say 'Post [ID]'
416
- assert_select('h2', :text => "Post #{@blog_post.id}")
417
- end
418
- end
@@ -1,189 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
2
-
3
- class Admin::BlogPosts4IntegrationTest < ActionController::IntegrationTest
4
- def setup
5
- User.destroy_all
6
- @user = User.create! :username => 'soren'
7
- end
8
-
9
- def test_index
10
- BlogPost.create!(
11
- :published_at => Time.utc(2009, 9, 1, 12, 30, 0), :user => @user,
12
- :title => 'whatever'
13
- )
14
- get "/admin/blog_posts4"
15
- assert_response :success
16
-
17
- # should show datetime stuff in the search form for published_at
18
- assert_select(
19
- 'form[id=search_form][method=get]', :text => /Title/
20
- ) do
21
- assert_select('select[name=?]', 'search[published_at(comparator)]') do
22
- assert_select("option[value=?]", ">", :text => 'greater than')
23
- assert_select("option[value=?]", "<", :text => 'less than')
24
- end
25
- nums_and_dt_fields = {
26
- 1 => :year, 2 => :month, 3 => :day, 4 => :hour, 5 => :min
27
- }
28
- nums_and_dt_fields.each do |num, dt_field|
29
- name = "search[published_at(#{num}i)]"
30
- value_for_now_option = Time.now.send(dt_field).to_s
31
- if [:hour, :min].include?(dt_field) && value_for_now_option.size == 1
32
- value_for_now_option = "0#{value_for_now_option}"
33
- end
34
- assert_select('select[name=?]', name) do
35
- assert_select "option[value='']"
36
- assert_select "option[value=?]", value_for_now_option
37
- end
38
- end
39
- assert_select(
40
- "a.clear_datetime_select[data-prefix=search_published_at]",
41
- :text => 'Clear'
42
- )
43
- end
44
-
45
- # should use strftime_format for displaying published_at
46
- assert_select('td', :text => "Sep 01, 2009 12:30:00")
47
- end
48
-
49
- def test_index_when_searching_by_published_at_with_a_greater_than_comparator
50
- @jun_blog_post = BlogPost.create!(
51
- :published_at => Time.utc(2009,6,1), :title => 'June', :user => @user
52
- )
53
- @aug_blog_post = BlogPost.create!(
54
- :published_at => Time.utc(2009,8,1), :title => 'August', :user => @user
55
- )
56
- get(
57
- "/admin/blog_posts4",
58
- :search => {
59
- :textile => '', :title => '', :user_id => '',
60
- 'published_at(comparator)' => '>',
61
- 'published_at(1i)' => '2009', 'published_at(2i)' => '7',
62
- 'published_at(3i)' => '1', 'published_at(4i)' => '1',
63
- 'published_at(5i)' => '1'
64
- }
65
- )
66
- assert_response :success
67
-
68
- # should include a blog post with a published_at time after the entered time
69
- assert_select('td', :text => 'August')
70
-
71
- # should not include a blog post with a published_at time before the entered time
72
- assert_no_match(%r|<td[^>]*>June</td>|, response.body)
73
-
74
- # should show the right fields pre-filled in the search form
75
- assert_select(
76
- 'form[id=search_form][method=get]', :text => /Title/
77
- ) do
78
- assert_select('select[name=?]', 'search[published_at(comparator)]') do
79
- assert_select(
80
- "option[value=?][selected=selected]", ">", :text => 'greater than'
81
- )
82
- assert_select("option[value=?]", "<", :text => 'less than')
83
- end
84
- assert_select('select[name=?]', 'search[published_at(1i)]') do
85
- assert_select "option[value=?][selected=selected]", "2009"
86
- end
87
- assert_select('select[name=?]', 'search[published_at(2i)]') do
88
- assert_select "option[value=?][selected=selected]", "7"
89
- end
90
- assert_select('select[name=?]', 'search[published_at(3i)]') do
91
- assert_select "option[value=?][selected=selected]", "1"
92
- end
93
- assert_select('select[name=?]', 'search[published_at(4i)]') do
94
- assert_select "option[value=?][selected=selected]", "01"
95
- end
96
- assert_select('select[name=?]', 'search[published_at(5i)]') do
97
- assert_select "option[value=?][selected=selected]", "01"
98
- end
99
- end
100
- end
101
-
102
- def test_index_when_searching_by_published_at_with_a_less_than_comparator
103
- @jun_blog_post = BlogPost.create!(
104
- :published_at => Time.utc(2009,6,1), :title => 'June', :user => @user
105
- )
106
- @aug_blog_post = BlogPost.create!(
107
- :published_at => Time.utc(2009,8,1), :title => 'August', :user => @user
108
- )
109
- get(
110
- "/admin/blog_posts4",
111
- :search => {
112
- :textile => '', :title => '', :user_id => '',
113
- 'published_at(comparator)' => '<',
114
- 'published_at(1i)' => '2009', 'published_at(2i)' => '7',
115
- 'published_at(3i)' => '1', 'published_at(4i)' => '1',
116
- 'published_at(5i)' => '1'
117
- }
118
- )
119
- assert_response :success
120
-
121
- # should not include a blog post with a published_at time after the entered time
122
- assert_no_match(%r|<td[^>]*>August</td>|, response.body)
123
-
124
- # should include a blog post with a published_at time before the entered time
125
- assert_select('td', :text => 'June')
126
-
127
- # should show the right fields pre-filled in the search form
128
- assert_select(
129
- 'form[id=search_form][method=get]', :text => /Title/
130
- ) do
131
- assert_select('select[name=?]', 'search[published_at(comparator)]') do
132
- assert_select "option[value=?]", ">", :text => 'greater than'
133
- assert_select(
134
- "option[value=?][selected=selected]", "<", :text => 'less than'
135
- )
136
- end
137
- assert_select('select[name=?]', 'search[published_at(1i)]') do
138
- assert_select "option[value=?][selected=selected]", "2009"
139
- end
140
- assert_select('select[name=?]', 'search[published_at(2i)]') do
141
- assert_select "option[value=?][selected=selected]", "7"
142
- end
143
- assert_select('select[name=?]', 'search[published_at(3i)]') do
144
- assert_select "option[value=?][selected=selected]", "1"
145
- end
146
- assert_select('select[name=?]', 'search[published_at(4i)]') do
147
- assert_select "option[value=?][selected=selected]", "01"
148
- end
149
- assert_select('select[name=?]', 'search[published_at(5i)]') do
150
- assert_select "option[value=?][selected=selected]", "01"
151
- end
152
- end
153
- end
154
-
155
- def test_index_with_26_unpublished_blog_posts
156
- BlogPost.destroy_all
157
- 1.upto(26) do |i|
158
- BlogPost.create!(
159
- :title => "--post #{i}--", :user => @user, :published_at => nil
160
- )
161
- end
162
- get "/admin/blog_posts4"
163
-
164
- # should not show link to page 2
165
- assert_select("a[href=/admin/blog_posts4?page=2]", false)
166
-
167
- # should only say 25 blog posts found
168
- assert_match(/25 blog posts found/, response.body)
169
- end
170
-
171
- def test_new
172
- get "/admin/blog_posts4/new"
173
-
174
- # should use a textarea for virtual_text
175
- assert_select("textarea[name=?]", "blog_post[virtual_text]")
176
- end
177
-
178
- def test_show
179
- @blog_post = BlogPost.create!(
180
- :published_at => Time.utc(2009, 9, 1, 12, 30, 0), :user => @user,
181
- :title => 'whatever'
182
- )
183
- get "/admin/blog_posts4/#{@blog_post.id}"
184
- assert_response :success
185
-
186
- # should use strftime_format for displaying published_at
187
- assert_match(/Sep 01, 2009 12:30:00/, response.body)
188
- end
189
- end