blogit 1.0.0.rc1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +28 -31
  3. data/Rakefile +6 -2
  4. data/app/assets/stylesheets/blogit/themes/default.css +4 -0
  5. data/app/assets/stylesheets/blogit/themes/default.css.map +7 -0
  6. data/app/assets/stylesheets/blogit/themes/default.min.css +2 -0
  7. data/app/assets/stylesheets/blogit/themes/default.min.css.map +7 -0
  8. data/app/assets/stylesheets/blogit/themes/default.sass +2 -0
  9. data/app/assets/stylesheets/blogit/themes/default/base/_colors.sass +1 -0
  10. data/app/assets/stylesheets/blogit/themes/default/base/_typography.sass +1 -0
  11. data/app/assets/stylesheets/blogit/themes/default/blocks/_archives.sass +18 -0
  12. data/app/assets/stylesheets/blogit/themes/default/blocks/_comments.sass +7 -0
  13. data/app/assets/stylesheets/blogit/themes/default/blocks/_forms.sass +9 -0
  14. data/app/assets/stylesheets/blogit/themes/default/blocks/_headers.sass +4 -0
  15. data/app/assets/stylesheets/blogit/themes/default/blocks/_posts.sass +8 -0
  16. data/app/assets/stylesheets/blogit/themes/default/blocks/_related_posts_list.sass +3 -0
  17. data/app/assets/stylesheets/blogit/themes/default/blocks/_share_bars.sass +7 -0
  18. data/app/{views/blogit/posts/_no_comments.html.erb → assets/stylesheets/blogit/themes/default/blocks/_tag_list.sass} +0 -0
  19. data/app/assets/stylesheets/blogit/themes/default/blocks/_tags.sass +4 -0
  20. data/app/controllers/blogit/application_controller.rb +15 -31
  21. data/app/controllers/blogit/comments_controller.rb +48 -30
  22. data/app/controllers/blogit/posts_controller.rb +52 -86
  23. data/app/helpers/blogit/application_helper.rb +59 -69
  24. data/app/helpers/blogit/comments_helper.rb +20 -0
  25. data/app/helpers/blogit/layout_helper.rb +33 -0
  26. data/app/helpers/blogit/posts_helper.rb +36 -34
  27. data/app/models/blogit/post.rb +55 -6
  28. data/app/views/blogit/archive/_list.html.erb +5 -0
  29. data/app/views/blogit/archive/_month.html.erb +9 -0
  30. data/app/views/blogit/archive/_year.html.erb +7 -0
  31. data/app/views/blogit/{posts → comments}/_active_record_comments.html.erb +2 -1
  32. data/app/views/blogit/comments/_comment.html.erb +10 -14
  33. data/app/views/blogit/comments/_comments_count.html.erb +8 -0
  34. data/app/views/blogit/{posts → comments}/_disqus_comments.html.erb +0 -0
  35. data/app/views/blogit/comments/_form.html.erb +25 -18
  36. data/app/views/blogit/comments/_no_comments.html.erb +0 -0
  37. data/app/views/blogit/comments/create.js.erb +2 -2
  38. data/app/views/blogit/posts/_archiveable.html.erb +3 -0
  39. data/app/views/blogit/posts/_blog_post_spacer.html.erb +1 -1
  40. data/app/views/blogit/posts/_blogger_information.html.erb +9 -4
  41. data/app/views/blogit/posts/_meta_tags.html.erb +32 -0
  42. data/app/views/blogit/posts/_post.html.erb +6 -9
  43. data/app/views/blogit/posts/_post_footer.html.erb +1 -0
  44. data/app/views/blogit/posts/_post_head.html.erb +3 -2
  45. data/app/views/blogit/posts/_related.html.erb +7 -16
  46. data/app/views/blogit/posts/_related_post.html.erb +4 -0
  47. data/app/views/blogit/posts/_share_bar.html.erb +5 -6
  48. data/app/views/blogit/posts/_tags.html.erb +8 -0
  49. data/app/views/blogit/posts/index.html.erb +16 -11
  50. data/app/views/blogit/posts/show.html.erb +28 -4
  51. data/app/views/blogit/tags/_tag.html.erb +3 -0
  52. data/config/locales/en.yml +3 -2
  53. data/config/spring.rb +1 -0
  54. data/db/migrate/20150618184415_add_description_to_posts.rb +5 -0
  55. data/lib/blogit.rb +4 -5
  56. data/lib/blogit/archive.rb +8 -0
  57. data/lib/blogit/archive/archive_error.rb +3 -0
  58. data/lib/blogit/archive/archiveable.rb +20 -0
  59. data/lib/blogit/archive/list.rb +52 -0
  60. data/lib/blogit/archive/month.rb +34 -0
  61. data/lib/blogit/archive/year.rb +40 -0
  62. data/lib/blogit/blogs.rb +11 -5
  63. data/lib/blogit/configuration.rb +157 -147
  64. data/lib/blogit/parsers/html_parser.rb +6 -3
  65. data/lib/blogit/parsers/markdown_parser.rb +30 -5
  66. data/lib/blogit/parsers/textile_parser.rb +18 -8
  67. data/lib/blogit/renderers/html_with_albino.rb +1 -1
  68. data/lib/blogit/version.rb +1 -1
  69. data/lib/generators/templates/blogit.rb +23 -57
  70. data/lib/tasks/blogit.rake +42 -0
  71. data/lib/tasks/blogit/css.rake +22 -0
  72. data/lib/tasks/blogit/doc.rake +21 -0
  73. data/lib/tasks/seed_blog_posts.yml +95 -0
  74. data/lib/validators/absence_validator.rb +2 -2
  75. data/spec/blogit_spec.rb +3 -3
  76. data/spec/controllers/blogit/comments_controller_spec.rb +31 -86
  77. data/spec/controllers/blogit/posts_controller_spec.rb +33 -344
  78. data/spec/dummy/Rakefile +1 -1
  79. data/spec/dummy/app/assets/stylesheets/application.sass +7 -0
  80. data/spec/dummy/app/assets/stylesheets/base.sass +1 -0
  81. data/spec/dummy/app/assets/stylesheets/base/_html.sass +15 -0
  82. data/spec/dummy/app/assets/stylesheets/blocks.sass +1 -0
  83. data/spec/dummy/app/assets/stylesheets/blocks/_layout.sass +21 -0
  84. data/spec/dummy/app/views/layouts/application.html.erb +21 -18
  85. data/spec/dummy/app/views/layouts/custom.html.erb +2 -1
  86. data/spec/dummy/config.ru +0 -1
  87. data/spec/dummy/config/application.rb +1 -0
  88. data/spec/dummy/config/database.yml +5 -3
  89. data/spec/dummy/config/environments/production.rb +7 -2
  90. data/spec/dummy/config/environments/test.rb +6 -1
  91. data/spec/dummy/db/development.sqlite3 +0 -0
  92. data/spec/dummy/db/migrate/{20140511174024_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb → 20150619080551_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb} +0 -0
  93. data/spec/dummy/db/migrate/{20140511174025_add_missing_unique_indices.acts_as_taggable_on_engine.rb → 20150619080552_add_missing_unique_indices.acts_as_taggable_on_engine.rb} +0 -0
  94. data/spec/dummy/db/migrate/{20140511174026_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb → 20150619080553_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb} +0 -0
  95. data/spec/dummy/db/migrate/20150619080554_add_missing_taggable_index.acts_as_taggable_on_engine.rb +10 -0
  96. data/spec/dummy/db/migrate/20150619080555_change_collation_for_tag_names.acts_as_taggable_on_engine.rb +10 -0
  97. data/spec/dummy/db/schema.rb +9 -7
  98. data/spec/dummy/db/seeds.rb +17 -0
  99. data/spec/dummy/lib/tasks/dummy.rake +29 -0
  100. data/spec/dummy/log/development.log +22286 -1489
  101. data/spec/dummy/log/test.log +4608 -11518
  102. data/spec/factories.rb +10 -5
  103. data/spec/helpers/blogit/application_helper_spec.rb +10 -73
  104. data/spec/helpers/blogit/posts_helper_spec.rb +8 -63
  105. data/spec/injectables/dummy_archiveable.rb +6 -0
  106. data/spec/lib/archive/list_spec.rb +60 -0
  107. data/spec/lib/archive/month_spec.rb +17 -0
  108. data/spec/lib/archive/year_spec.rb +38 -0
  109. data/spec/lib/blogit/parsers/html_parser_spec.rb +1 -1
  110. data/spec/lib/blogit/parsers/markdown_parser_spec.rb +7 -6
  111. data/spec/lib/blogit/parsers/textile_parser_spec.rb +1 -1
  112. data/spec/lib/blogs_spec.rb +2 -2
  113. data/spec/lib/configuration_spec.rb +21 -49
  114. data/spec/models/blogit/comment_spec.rb +19 -19
  115. data/spec/models/blogit/post_spec.rb +63 -28
  116. data/spec/rails_helper.rb +28 -0
  117. data/spec/spec_helper.rb +2 -11
  118. data/spec/support/helpers/css_matchers.rb +42 -0
  119. metadata +193 -124
  120. data/app/assets/stylesheets/blogit/index.css +0 -84
  121. data/app/views/blogit/comments/_admin_links.html.erb +0 -3
  122. data/app/views/blogit/posts/_comments_count.html.erb +0 -5
  123. data/app/views/blogit/posts/_form.html.erb +0 -49
  124. data/app/views/blogit/posts/_post_body.html.erb +0 -1
  125. data/app/views/blogit/posts/_post_links.html.erb +0 -6
  126. data/app/views/blogit/posts/edit.html.erb +0 -3
  127. data/app/views/blogit/posts/new.html.erb +0 -3
  128. data/lib/tasks/blog_tasks.rake +0 -4
  129. data/spec/dummy/app/assets/stylesheets/application.css +0 -21
  130. data/spec/dummy/config/initializers/blogit.rb +0 -88
  131. data/spec/dummy/db/migrate/20140511174028_create_blogit_posts.blogit.rb +0 -16
  132. data/spec/dummy/db/migrate/20140511174029_create_blogit_comments.blogit.rb +0 -16
  133. data/spec/dummy/db/test.sqlite3 +0 -0
  134. data/spec/dummy/tmp/cache/assets/CB5/DD0/sprockets%2F346324d2a51df58457807bee661c449c +0 -0
  135. data/spec/dummy/tmp/cache/assets/CB6/ED0/sprockets%2F4390d06699f3ad4262e342be530f9f91 +0 -0
  136. data/spec/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  137. data/spec/dummy/tmp/cache/assets/CE7/230/sprockets%2F6f493a817d97133a8dbf674bcd322670 +0 -0
  138. data/spec/dummy/tmp/cache/assets/CEA/490/sprockets%2F9697d4fb1ed26d80f3c715611c8d4373 +0 -0
  139. data/spec/dummy/tmp/cache/assets/CEE/310/sprockets%2F89642af8492e579dcd7162a0e2b7f155 +0 -0
  140. data/spec/dummy/tmp/cache/assets/D01/8C0/sprockets%2F332d5a9ce3e800c6c4a7a99058023ba2 +0 -0
  141. data/spec/dummy/tmp/cache/assets/D11/CC0/sprockets%2F3a12dfa6665b5318fa99d097203ac7e7 +0 -0
  142. data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  143. data/spec/dummy/tmp/cache/assets/D3D/1E0/sprockets%2Ffbaabd57fa2c9d426f0c318156705667 +0 -0
  144. data/spec/dummy/tmp/cache/assets/D3E/920/sprockets%2F3efa8d0fc958c223647cb704183b65ca +0 -0
  145. data/spec/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  146. data/spec/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  147. data/spec/dummy/tmp/cache/assets/D61/6F0/sprockets%2F02da53eeca228bcef0c49278517111fe +0 -0
  148. data/spec/dummy/tmp/cache/assets/DCA/9B0/sprockets%2Fdf0e8f8a85e5d4056b3fe1cec3b7131a +0 -0
  149. data/spec/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  150. data/spec/dummy/tmp/cache/assets/E02/A60/sprockets%2Fb32faeede196f7a933c3a2794e7ed0bd +0 -0
  151. data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  152. data/spec/dummy/tmp/cache/assets/development/sprockets/02da53eeca228bcef0c49278517111fe +0 -0
  153. data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  154. data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  155. data/spec/dummy/tmp/cache/assets/development/sprockets/2ff93f9f5ed9970021c7704ff93237c8 +0 -0
  156. data/spec/dummy/tmp/cache/assets/development/sprockets/332d5a9ce3e800c6c4a7a99058023ba2 +0 -0
  157. data/spec/dummy/tmp/cache/assets/development/sprockets/346324d2a51df58457807bee661c449c +0 -0
  158. data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  159. data/spec/dummy/tmp/cache/assets/development/sprockets/3a12dfa6665b5318fa99d097203ac7e7 +0 -0
  160. data/spec/dummy/tmp/cache/assets/development/sprockets/3ed52366904e135bd833590814b6ac6d +0 -0
  161. data/spec/dummy/tmp/cache/assets/development/sprockets/4390d06699f3ad4262e342be530f9f91 +0 -0
  162. data/spec/dummy/tmp/cache/assets/development/sprockets/6f493a817d97133a8dbf674bcd322670 +0 -0
  163. data/spec/dummy/tmp/cache/assets/development/sprockets/89642af8492e579dcd7162a0e2b7f155 +0 -0
  164. data/spec/dummy/tmp/cache/assets/development/sprockets/89dc196c51ae83634b664c0c33052008 +0 -0
  165. data/spec/dummy/tmp/cache/assets/development/sprockets/8dd8236b00c868ba248fe30cd9c14c2a +0 -0
  166. data/spec/dummy/tmp/cache/assets/development/sprockets/9239a04d094a872c1cf77ac391072ea8 +0 -0
  167. data/spec/dummy/tmp/cache/assets/development/sprockets/b3ffb6bd243399012806331ce393ae4f +0 -0
  168. data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  169. data/spec/dummy/tmp/cache/assets/development/sprockets/d53accc3e58037ee4005e41221b8846b +0 -0
  170. data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  171. data/spec/dummy/tmp/cache/assets/development/sprockets/df0e8f8a85e5d4056b3fe1cec3b7131a +0 -0
  172. data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  173. data/spec/routing/post_routing_spec.rb +0 -49
@@ -1,9 +1,10 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
3
  describe Blogit::PostsController do
4
4
 
5
5
  before do
6
6
  reset_configuration
7
+ @routes = Blogit::Engine.routes
7
8
  end
8
9
 
9
10
  let(:blog_post) { build :post }
@@ -13,62 +14,38 @@ describe Blogit::PostsController do
13
14
  let(:posts) { [] }
14
15
 
15
16
  def do_get(page=nil)
16
- get :index, :use_route => :blogit, page: page.to_s
17
+ get :index, page: page
17
18
  end
18
19
 
19
- context 'when user is logged in' do
20
-
21
- before(:each) do
22
- controller.stubs(:is_blogger_logged_in?).returns(false)
23
- Blogit::Post.stubs(:active).returns(posts)
24
- end
25
-
26
- it 'should set posts to Blogit::Post.active.for_index' do
27
- Blogit::Post.stubs(:for_index).returns(posts)
28
- Blogit::Post.active.expects(:for_index).returns(posts)
29
- do_get
30
- assigns(:posts).should == posts
31
- end
20
+ it 'sets posts to Blogit::Post.for_index' do
21
+ Blogit::Post.expects(:for_index).returns(posts)
22
+ do_get
23
+ expect(assigns(:posts)).to eql(posts)
24
+ end
25
+
26
+ context "when a page param is present" do
32
27
 
33
- it 'should pass the page param to Blogit::Post.active.for_index' do
34
- Blogit::Post.stubs(:for_index).with('2').returns(posts)
35
- Blogit::Post.active.expects(:for_index).with('2').returns(posts)
28
+ it 'passes the page param on to Blogit::Post.for_index' do
29
+ Blogit::Post.expects(:for_index).with('2').returns(posts)
36
30
  do_get('2')
37
- assigns(:posts).should == posts
31
+ expect(assigns(:posts)).to eql(posts)
38
32
  end
33
+
39
34
  end
40
35
 
41
- context 'when user is not logged in' do
42
- before(:each) do
43
- controller.stubs(:is_blogger_logged_in?).returns(true)
36
+ context "when a custom layout is set" do
37
+
38
+ before do
39
+ Blogit.configuration.layout = "custom"
40
+ # Force re-load the Blogit::PostsController
41
+ load(File.join(File.dirname(__FILE__), "../../..", "app", "controllers",
42
+ "blogit", "posts_controller.rb"))
44
43
  end
45
-
46
- it 'sets posts to Blogit::Post.for_index' do
47
- Blogit::Post.expects(:for_index).returns(posts)
44
+
45
+ it "uses use the specified layout" do
48
46
  do_get
49
- assigns(:posts).should == posts
50
- end
51
-
52
- it 'should pass the page param to Blogit::Post.active.for_index' do
53
- Blogit::Post.expects(:for_index).with('2').returns(posts)
54
- do_get('2')
55
- assigns(:posts).should == posts
47
+ expect(response).to render_template("layouts/custom")
56
48
  end
57
- end
58
-
59
- describe "when layout is set" do
60
-
61
- # TODO: Think of a way to test this. The PostsController is being cached
62
- # because cache-classes is set to true but that means the layout is not
63
- # being changed.
64
- #
65
- # This works in practice but not in testing
66
- # it "should use the specified layout" do
67
- # reset_configuration
68
- # Blogit.configuration.layout = "custom"
69
- # do_get
70
- # response.should.should render_template("layouts/custom")
71
- # end
72
49
 
73
50
  end
74
51
 
@@ -80,234 +57,14 @@ describe Blogit::PostsController do
80
57
  let(:posts) { [] }
81
58
 
82
59
  def do_get(page=nil)
83
- get :index, :use_route => :blogit, page: page.to_s, format: :xml
60
+ get :index, page: page.to_s, format: :xml
84
61
  end
85
62
 
86
- it "should load all posts in reverse date order" do
63
+ it "loads all posts in reverse date order" do
87
64
  Blogit::Post.stubs(:active).returns(posts)
88
- Blogit::Post.active.expects(:order).with('created_at DESC').returns(posts)
65
+ Blogit::Post.expects(:for_feed).returns(posts)
89
66
  do_get
90
- assigns(:posts).should == posts
91
- end
92
-
93
- end
94
-
95
- describe "GET 'new'" do
96
-
97
- context "when logged in" do
98
-
99
- before do
100
- mock_login
101
- end
102
-
103
- def do_get
104
- get :new, use_route: :blogit
105
- end
106
-
107
- it "should be successful" do
108
- do_get
109
- response.should be_success
110
- end
111
-
112
- it "should set post to a new blog post" do
113
- do_get
114
- assigns(:post).should be_a(Blogit::Post)
115
- assigns(:post).should be_a_new_record
116
- end
117
-
118
- end
119
-
120
- context "when not logged in" do
121
-
122
- def do_get
123
- get :new, use_route: :blogit
124
- end
125
-
126
- # It's not really the responsibility of the gem to manage authentication
127
- # so testing for specific behaviour here is not required
128
- # at the very least though, we'd expect the status not to be 200
129
- it "should redirect to another page" do
130
- do_get
131
- response.should_not be_success
132
- end
133
-
134
- end
135
- end
136
-
137
- describe "POST /create" do
138
-
139
- context "when logged in" do
140
-
141
- before do
142
- mock_login
143
- end
144
-
145
- context "with valid params" do
146
-
147
- let(:post_attributes) { attributes_for(:post) }
148
-
149
- def do_post
150
- post :create, use_route: :blogit, post: post_attributes
151
- end
152
-
153
- before do
154
- @blog_posts = []
155
- @current_blogger.expects(:blog_posts).returns(@blog_posts)
156
- @blog_posts.expects(:new).with(post_attributes.stringify_keys).returns(blog_post)
157
- blog_post.expects(:save).returns(true)
158
- @pingr = mock()
159
- @pingr.stub_everything()
160
- end
161
-
162
- it "should redirect to the blog post page" do
163
- do_post
164
- response.should redirect_to(controller.posts_url)
165
- end
166
-
167
- it "should ping all search engines in ping_search_engines config if array" do
168
- Blogit.configuration.ping_search_engines = search_engines = [:google]
169
- search_engines.each do |search_engine|
170
- Pingr::Request.expects(:new).with(search_engine, controller.posts_url(format: :xml)).returns(@pingr)
171
- end
172
- do_post
173
- end
174
-
175
- it "should ping all search engines in Pingr::SUPPORTED_SEARCH_ENGINES if config is true" do
176
- Blogit.configuration.ping_search_engines = true
177
- Pingr::SUPPORTED_SEARCH_ENGINES.each do |search_engine|
178
- Pingr::Request.expects(:new).with(search_engine, controller.posts_url(format: :xml)).returns(@pingr)
179
- end
180
- do_post
181
- end
182
-
183
- it "should not ping any search engines if ping_search_engines is false" do
184
- Blogit.configuration.ping_search_engines = false
185
- Pingr::SUPPORTED_SEARCH_ENGINES.each do |search_engine|
186
- Pingr::Request.expects(:new).with(search_engine, controller.posts_url(format: :xml)).never
187
- end
188
- do_post
189
- end
190
- end
191
-
192
- end
193
-
194
- end
195
-
196
- describe "GET 'edit'" do
197
-
198
- context "when logged in" do
199
-
200
- before do
201
- mock_login
202
- @current_blogger.expects(:blog_posts).returns(@blog_posts = [])
203
- @blog_posts.expects(:find).with("1").returns(blog_post)
204
- end
205
-
206
- def do_get
207
- get :edit, :id => 1, use_route: :blogit
208
- end
209
-
210
- it "should find the blog post by the ID" do
211
- do_get
212
- assigns(:post).should eql(blog_post)
213
- end
214
-
215
- end
216
-
217
- context "when not logged in" do
218
-
219
- def do_get
220
- get :edit, :id => 1, use_route: :blogit
221
- end
222
-
223
- # It's not really the responsibility of the gem to manage authentication
224
- # so testing for specific behaviour here is not required
225
- # at the very least though, we'd expect the status not to be 200
226
- it "should redirect to another pages" do
227
- do_get
228
- response.should_not be_success
229
- end
230
-
231
- end
232
-
233
- end
234
-
235
- describe "PUT 'update'" do
236
-
237
- context "when logged in" do
238
-
239
- before do
240
- @post_attributes = {"title" => "Something new"}
241
- mock_login
242
- @current_blogger.expects(:blog_posts).returns(@blog_posts = [])
243
- @blog_posts.expects(:find).with("1").returns(blog_post)
244
- @pingr = mock()
245
- @pingr.stub_everything()
246
- end
247
-
248
- def do_put
249
- put :update, id: "1", use_route: :blogit, post: @post_attributes
250
- end
251
-
252
- it "should update the post attributes from params" do
253
- blog_post.expects(:update_attributes).with(@post_attributes).returns(true)
254
- do_put
255
- end
256
-
257
- it "should redirect to the blog post page" do
258
- do_put
259
- response.should redirect_to(controller.post_url(blog_post))
260
- end
261
-
262
- it "should set a flash notice" do
263
- do_put
264
- flash[:notice].should be_present
265
- end
266
-
267
- it "should ping all search engines in ping_search_engines config if array" do
268
- Blogit.configuration.ping_search_engines = search_engines = [:google, :bing]
269
- search_engines.each do |search_engine|
270
- Pingr::Request.expects(:new).with(search_engine, controller.posts_url(format: :xml)).returns(@pingr)
271
- end
272
- do_put
273
- end
274
-
275
- it "should ping all search engines in Pingr::SUPPORTED_SEARCH_ENGINES if config is true" do
276
- Blogit.configuration.ping_search_engines = true
277
- Pingr::SUPPORTED_SEARCH_ENGINES.each do |search_engine|
278
- Pingr::Request.expects(:new).with(search_engine, controller.posts_url(format: :xml)).returns(@pingr)
279
- end
280
- do_put
281
- end
282
-
283
- it "should not ping any search engines if ping_search_engines is false" do
284
- Blogit.configuration.ping_search_engines = false
285
- Pingr::SUPPORTED_SEARCH_ENGINES.each do |search_engine|
286
- Pingr::Request.expects(:new).with(search_engine, controller.posts_url(format: :xml)).never
287
- end
288
- do_put
289
- end
290
-
291
- end
292
-
293
- context "when not logged in" do
294
-
295
- before do
296
- @post_attributes = {"title" => "Something new"}
297
- end
298
-
299
- def do_put
300
- put :update, id: "1", use_route: :blogit, post: @post_attributes
301
- end
302
-
303
- # It's not really the responsibility of the gem to manage authentication
304
- # so testing for specific behaviour here is not required
305
- # at the very least though, we'd expect the status not to be 200
306
- it "should redirect to another page" do
307
- do_put
308
- response.should_not be_success
309
- end
310
-
67
+ expect(assigns(:posts)).to eql(posts)
311
68
  end
312
69
 
313
70
  end
@@ -315,86 +72,18 @@ describe Blogit::PostsController do
315
72
  describe "GET 'show'" do
316
73
 
317
74
  before do
318
- Blogit::Post.expects(:find).with("1").returns(blog_post)
75
+ Blogit::Post.expects(:active_with_id).with("1").returns(blog_post)
319
76
  end
320
77
 
321
78
  def do_get
322
- get :show, :id => 1, use_route: :blogit
79
+ get :show, :id => 1
323
80
  end
324
81
 
325
- it "should find blog post by id" do
82
+ it "finds blog post by id" do
326
83
  do_get
327
- assigns(:post).should eql(blog_post)
328
- end
329
-
330
- end
331
-
332
- describe "DELETE 'destroy'" do
333
-
334
- def do_delete
335
- delete :destroy, id: "1", use_route: :blogit
336
- end
337
-
338
- describe "when logged in" do
339
-
340
- before do
341
- mock_login
342
- @current_blogger.expects(:blog_posts).returns(@blog_posts = [])
343
- @blog_posts.expects(:find).with("1").returns(blog_post)
344
- @pingr = mock()
345
- @pingr.stub_everything()
346
- end
347
-
348
- it "should destroy the blog post" do
349
- blog_post.expects(:destroy)
350
- do_delete
351
- end
352
-
353
- it "should redirect to the blog posts url" do
354
- do_delete
355
- response.should redirect_to(controller.posts_url)
356
- end
357
-
358
- it "should show a flash notice" do
359
- do_delete
360
- flash[:notice].should be_present
361
- end
362
-
363
- it "should ping all search engines in ping_search_engines config if array" do
364
- Blogit.configuration.ping_search_engines = search_engines = [:google, :bing]
365
- search_engines.each do |search_engine|
366
- Pingr::Request.expects(:new).with(search_engine, controller.posts_url(format: :xml)).returns(@pingr)
367
- end
368
- do_delete
369
- end
370
-
371
- it "should ping all search engines in Pingr::SUPPORTED_SEARCH_ENGINES if config is true" do
372
- Blogit.configuration.ping_search_engines = true
373
- Pingr::SUPPORTED_SEARCH_ENGINES.each do |search_engine|
374
- Pingr::Request.expects(:new).with(search_engine, controller.posts_url(format: :xml)).returns(@pingr)
375
- end
376
- do_delete
377
- end
378
-
379
- it "should not ping any search engines if ping_search_engines is false" do
380
- Blogit.configuration.ping_search_engines = false
381
- Pingr::SUPPORTED_SEARCH_ENGINES.each do |search_engine|
382
- Pingr::Request.expects(:new).with(search_engine, controller.posts_url(format: :xml)).never
383
- end
384
- do_delete
385
- end
386
-
387
- end
388
-
389
- describe "when not logged in" do
390
-
391
- it "should redirect to another page" do
392
- do_delete
393
- response.should_not be_success
394
- end
395
-
84
+ expect(assigns(:post)).to eql(blog_post)
396
85
  end
397
86
 
398
87
  end
399
88
 
400
- end
89
+ end
@@ -4,4 +4,4 @@
4
4
 
5
5
  require File.expand_path('../config/application', __FILE__)
6
6
 
7
- Dummy::Application.load_tasks
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,7 @@
1
+ /* =================================== */
2
+ /* = Some CSS for the dummy app only = */
3
+ /* =================================== */
4
+
5
+ @import "base"
6
+ @import "blocks"
7
+ @import "blogit/themes/default"
@@ -0,0 +1 @@
1
+ @import "base/*"
@@ -0,0 +1,15 @@
1
+
2
+
3
+ body
4
+ font-size: 15px
5
+ line-height: 1.5em
6
+ font-family: "open sans", Arial, sans-serif
7
+
8
+
9
+ h1
10
+ margin: 1em 0
11
+ font-size: 3em
12
+ line-height: 1.4
13
+
14
+ a
15
+ text-decoration: none