blogit 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/app/controllers/blogit/comments_controller.rb +4 -1
- data/app/controllers/blogit/posts_controller.rb +9 -0
- data/app/helpers/blogit/application_helper.rb +20 -9
- data/app/models/blogit/post.rb +19 -17
- data/app/views/blogit/posts/_post.html.erb +1 -1
- data/lib/blogit/version.rb +1 -1
- data/lib/tasks/blogit.rake +0 -1
- data/spec/controllers/blogit/comments_controller_spec.rb +1 -1
- data/spec/dummy/app/controllers/sub_comments_controller.rb +10 -0
- data/spec/dummy/app/controllers/sub_posts_controller.rb +22 -0
- data/spec/dummy/config/routes.rb +8 -0
- data/spec/dummy/log/test.log +4595 -0
- data/spec/dummy/spec/controllers/sub_comments_controller.rb +46 -0
- data/spec/dummy/spec/controllers/sub_posts_controller_spec.rb +88 -0
- data/spec/models/blogit/post_spec.rb +23 -20
- data/spec/spec_helper.rb +3 -0
- metadata +37 -1
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe SubCommentsController do
|
4
|
+
|
5
|
+
it "is a subclass of Blogit::CommentsController" do
|
6
|
+
expect(SubCommentsController.superclass).to eq(Blogit::CommentsController)
|
7
|
+
end
|
8
|
+
|
9
|
+
before do
|
10
|
+
reset_configuration
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:blog_post) { build :post }
|
14
|
+
|
15
|
+
describe "POST 'create'" do
|
16
|
+
|
17
|
+
before do
|
18
|
+
Post.expects(:active_with_id).with("1").returns(blog_post)
|
19
|
+
blog_post.expects(:comments).returns(relation_obj)
|
20
|
+
relation_obj.expects(:new).returns(comment)
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:relation_obj) { stub }
|
24
|
+
|
25
|
+
let(:blog_post) { build(:post) }
|
26
|
+
|
27
|
+
let(:comment) { build(:comment) }
|
28
|
+
|
29
|
+
def do_post(post_id = "1")
|
30
|
+
post :create, post_id: post_id, comment: attributes_for(:comment)
|
31
|
+
end
|
32
|
+
|
33
|
+
context "when super is called with a block" do
|
34
|
+
|
35
|
+
it 'yields the block with comment' do
|
36
|
+
Timecop.freeze do
|
37
|
+
comment.expects(:touch).with(:updated_at)
|
38
|
+
do_post
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe SubPostsController do
|
4
|
+
|
5
|
+
it "is a subclass of Blogit::PostsController" do
|
6
|
+
expect(SubPostsController.superclass).to eq(Blogit::PostsController)
|
7
|
+
end
|
8
|
+
|
9
|
+
before do
|
10
|
+
reset_configuration
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:blog_post) { build :post }
|
14
|
+
|
15
|
+
describe "GET 'index'" do
|
16
|
+
|
17
|
+
before do
|
18
|
+
Post.expects(:for_index).with(nil).returns(posts)
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:posts) { [] }
|
22
|
+
|
23
|
+
def do_get(page=nil)
|
24
|
+
get :index, page: page
|
25
|
+
end
|
26
|
+
|
27
|
+
context "when super is called with a block" do
|
28
|
+
|
29
|
+
it 'yields the block with posts' do
|
30
|
+
Timecop.freeze do
|
31
|
+
posts.expects(:update_all).with(updated_at: Time.now).returns([])
|
32
|
+
do_get
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "GET 'tagged'" do
|
41
|
+
|
42
|
+
before do
|
43
|
+
Post.expects(:for_index).with(nil).returns(posts)
|
44
|
+
posts.expects(:tagged_with).returns(posts)
|
45
|
+
end
|
46
|
+
|
47
|
+
let(:posts) { [] }
|
48
|
+
|
49
|
+
def do_get(page=nil)
|
50
|
+
get :tagged, page: page, tag: "one"
|
51
|
+
end
|
52
|
+
|
53
|
+
context "when super is called with a block" do
|
54
|
+
|
55
|
+
it 'yields the block with posts' do
|
56
|
+
Timecop.freeze do
|
57
|
+
posts.expects(:update_all).with(updated_at: Time.now).returns([])
|
58
|
+
do_get
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "GET 'show'" do
|
67
|
+
|
68
|
+
before do
|
69
|
+
Post.expects(:active_with_id).with("1").returns(post)
|
70
|
+
end
|
71
|
+
|
72
|
+
let(:post) { [] }
|
73
|
+
|
74
|
+
def do_get(id="1")
|
75
|
+
get :show, id: "1"
|
76
|
+
end
|
77
|
+
|
78
|
+
context "when super is called with a block" do
|
79
|
+
|
80
|
+
it 'yields the block with posts' do
|
81
|
+
post.expects(:touch).with(:updated_at)
|
82
|
+
do_get
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
@@ -164,25 +164,34 @@ describe Blogit::Post do
|
|
164
164
|
|
165
165
|
end
|
166
166
|
|
167
|
-
describe
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
167
|
+
describe :short_body do
|
168
|
+
|
169
|
+
let(:post) { build(:post) }
|
170
|
+
|
171
|
+
context "when Blogit.configuration.show_post_description is true" do
|
172
|
+
|
173
|
+
before do
|
174
|
+
Blogit.configuration.show_post_description = true
|
175
|
+
end
|
176
|
+
|
177
|
+
it "returns the Post's description" do
|
178
|
+
expect(post.short_body).to eq(post.description)
|
179
|
+
end
|
180
|
+
|
172
181
|
end
|
173
182
|
|
174
|
-
|
175
|
-
|
183
|
+
context "when Blogit.configuration.show_post_description is false" do
|
184
|
+
|
185
|
+
before do
|
186
|
+
Blogit.configuration.show_post_description = false
|
187
|
+
end
|
176
188
|
|
177
|
-
|
189
|
+
it "returns the Post's description" do
|
190
|
+
expect(post.short_body).to eq(post.body)
|
191
|
+
end
|
192
|
+
|
178
193
|
end
|
179
194
|
|
180
|
-
it "should not cut the body in the middle of an image declaration" do
|
181
|
-
body = "some text\n"*35 + '"!http://www.images.com/blogit/P6876.thumb.jpg(Look at this)!\":http://www.images.com/blogit/P6976.jpb'
|
182
|
-
post = Blogit::Post.new(body: body)
|
183
|
-
|
184
|
-
expect(post.short_body).not_to include('"!http://www.images.com')
|
185
|
-
end
|
186
195
|
end
|
187
196
|
|
188
197
|
describe "blogger_twitter_username" do
|
@@ -218,10 +227,4 @@ describe Blogit::Post do
|
|
218
227
|
end
|
219
228
|
end
|
220
229
|
|
221
|
-
describe 'AVAILABLE_STATUS' do
|
222
|
-
it "returns all the statues in Blogit::configuration" do
|
223
|
-
expect(Blogit::Post::AVAILABLE_STATUS).to eq(Blogit.configuration.hidden_states + Blogit.configuration.active_states)
|
224
|
-
end
|
225
|
-
|
226
|
-
end
|
227
230
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blogit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bodacious
|
@@ -206,6 +206,20 @@ dependencies:
|
|
206
206
|
- - ">="
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: codeclimate-test-reporter
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
209
223
|
- !ruby/object:Gem::Dependency
|
210
224
|
name: spring
|
211
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -388,6 +402,20 @@ dependencies:
|
|
388
402
|
- - ">="
|
389
403
|
- !ruby/object:Gem::Version
|
390
404
|
version: '0'
|
405
|
+
- !ruby/object:Gem::Dependency
|
406
|
+
name: timecop
|
407
|
+
requirement: !ruby/object:Gem::Requirement
|
408
|
+
requirements:
|
409
|
+
- - ">="
|
410
|
+
- !ruby/object:Gem::Version
|
411
|
+
version: '0'
|
412
|
+
type: :development
|
413
|
+
prerelease: false
|
414
|
+
version_requirements: !ruby/object:Gem::Requirement
|
415
|
+
requirements:
|
416
|
+
- - ">="
|
417
|
+
- !ruby/object:Gem::Version
|
418
|
+
version: '0'
|
391
419
|
description: Add a blog to your Rails application in minutes with this mountable Rails
|
392
420
|
Engine
|
393
421
|
email:
|
@@ -507,6 +535,8 @@ files:
|
|
507
535
|
- spec/dummy/app/controllers/application_controller.rb
|
508
536
|
- spec/dummy/app/controllers/people_controller.rb
|
509
537
|
- spec/dummy/app/controllers/sessions_controller.rb
|
538
|
+
- spec/dummy/app/controllers/sub_comments_controller.rb
|
539
|
+
- spec/dummy/app/controllers/sub_posts_controller.rb
|
510
540
|
- spec/dummy/app/controllers/users_controller.rb
|
511
541
|
- spec/dummy/app/helpers/application_helper.rb
|
512
542
|
- spec/dummy/app/helpers/people_helper.rb
|
@@ -561,6 +591,8 @@ files:
|
|
561
591
|
- spec/dummy/public/500.html
|
562
592
|
- spec/dummy/public/favicon.ico
|
563
593
|
- spec/dummy/script/rails
|
594
|
+
- spec/dummy/spec/controllers/sub_comments_controller.rb
|
595
|
+
- spec/dummy/spec/controllers/sub_posts_controller_spec.rb
|
564
596
|
- spec/factories.rb
|
565
597
|
- spec/helpers/blogit/application_helper_spec.rb
|
566
598
|
- spec/helpers/blogit/posts_helper_spec.rb
|
@@ -616,6 +648,8 @@ test_files:
|
|
616
648
|
- spec/dummy/app/controllers/application_controller.rb
|
617
649
|
- spec/dummy/app/controllers/people_controller.rb
|
618
650
|
- spec/dummy/app/controllers/sessions_controller.rb
|
651
|
+
- spec/dummy/app/controllers/sub_comments_controller.rb
|
652
|
+
- spec/dummy/app/controllers/sub_posts_controller.rb
|
619
653
|
- spec/dummy/app/controllers/users_controller.rb
|
620
654
|
- spec/dummy/app/helpers/application_helper.rb
|
621
655
|
- spec/dummy/app/helpers/people_helper.rb
|
@@ -671,6 +705,8 @@ test_files:
|
|
671
705
|
- spec/dummy/public/favicon.ico
|
672
706
|
- spec/dummy/Rakefile
|
673
707
|
- spec/dummy/script/rails
|
708
|
+
- spec/dummy/spec/controllers/sub_comments_controller.rb
|
709
|
+
- spec/dummy/spec/controllers/sub_posts_controller_spec.rb
|
674
710
|
- spec/factories.rb
|
675
711
|
- spec/helpers/blogit/application_helper_spec.rb
|
676
712
|
- spec/helpers/blogit/posts_helper_spec.rb
|