comfy_blog 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/issue_template.md +22 -0
- data/.github/pull_request_template.md +6 -0
- data/.rubocop.yml +96 -0
- data/.travis.yml +2 -1
- data/CONTRIBUTING.md +32 -0
- data/Gemfile +8 -8
- data/README.md +1 -0
- data/Rakefile +1 -1
- data/app/controllers/comfy/admin/blog/posts_controller.rb +19 -11
- data/app/controllers/comfy/admin/blog/revisions/post_controller.rb +9 -3
- data/app/controllers/comfy/blog/posts_controller.rb +15 -12
- data/app/models/comfy/blog/post.rb +13 -12
- data/app/views/comfy/admin/blog/posts/_form.html.haml +2 -2
- data/app/views/comfy/admin/blog/posts/form_fragments.js.erb +1 -0
- data/app/views/comfy/blog/posts/index.rss.builder +4 -4
- data/bin/bundle +3 -0
- data/bin/rails +4 -0
- data/bin/rake +4 -0
- data/bin/setup +36 -0
- data/bin/update +31 -0
- data/bin/yarn +11 -0
- data/comfy_blog.gemspec +6 -6
- data/config.ru +2 -2
- data/config/application.rb +5 -4
- data/config/boot.rb +3 -3
- data/config/environment.rb +1 -1
- data/config/environments/development.rb +2 -2
- data/config/environments/test.rb +1 -1
- data/config/initializers/comfy_blog.rb +0 -2
- data/lib/comfy_blog.rb +10 -10
- data/lib/comfy_blog/configuration.rb +1 -1
- data/lib/comfy_blog/engine.rb +12 -7
- data/lib/comfy_blog/routes/blog.rb +8 -8
- data/lib/comfy_blog/routes/blog_admin.rb +5 -3
- data/lib/comfy_blog/routing.rb +2 -2
- data/lib/comfy_blog/version.rb +3 -1
- data/lib/generators/comfy/blog/blog_generator.rb +9 -9
- data/test/controllers/comfy/admin/blog/posts_controller_test.rb +53 -32
- data/test/controllers/comfy/admin/blog/revisions/post_controller_test.rb +6 -6
- data/test/controllers/comfy/blog/posts_controller_test.rb +7 -6
- data/test/gemfiles/Gemfile.rails.5.2 +5 -4
- data/test/generators/blog_generator_test.rb +7 -6
- data/test/integration/i18n_test.rb +8 -7
- data/test/lib/configuration_test.rb +4 -3
- data/test/models/posts_test.rb +12 -11
- data/test/test_helper.rb +24 -21
- metadata +15 -5
- data/script/rails +0 -6
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "../../../../test_helper"
|
2
2
|
|
3
3
|
class Comfy::Admin::Blog::PostsControllerTest < ActionDispatch::IntegrationTest
|
4
4
|
|
@@ -24,12 +24,12 @@ class Comfy::Admin::Blog::PostsControllerTest < ActionDispatch::IntegrationTest
|
|
24
24
|
|
25
25
|
def test_get_index_with_category
|
26
26
|
category = @site.categories.create!(
|
27
|
-
label:
|
28
|
-
categorized_type:
|
27
|
+
label: "Test Category",
|
28
|
+
categorized_type: "Comfy::Blog::Post"
|
29
29
|
)
|
30
30
|
category.categorizations.create!(categorized: @post)
|
31
31
|
|
32
|
-
r :get, comfy_admin_blog_posts_path(@site), params: {categories: category.label}
|
32
|
+
r :get, comfy_admin_blog_posts_path(@site), params: { categories: category.label }
|
33
33
|
assert_response :success
|
34
34
|
assert assigns(:posts)
|
35
35
|
assert_equal 1, assigns(:posts).count
|
@@ -37,7 +37,7 @@ class Comfy::Admin::Blog::PostsControllerTest < ActionDispatch::IntegrationTest
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_get_index_with_category_invalid
|
40
|
-
r :get, comfy_admin_blog_posts_path(@site), params: {categories:
|
40
|
+
r :get, comfy_admin_blog_posts_path(@site), params: { categories: "invalid" }
|
41
41
|
assert_response :success
|
42
42
|
assert assigns(:posts)
|
43
43
|
assert_equal 0, assigns(:posts).count
|
@@ -52,33 +52,33 @@ class Comfy::Admin::Blog::PostsControllerTest < ActionDispatch::IntegrationTest
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def test_creation
|
55
|
-
post_count = -> {Comfy::Blog::Post.count}
|
56
|
-
frag_count = -> {Comfy::Cms::Fragment.count}
|
55
|
+
post_count = -> { Comfy::Blog::Post.count }
|
56
|
+
frag_count = -> { Comfy::Cms::Fragment.count }
|
57
57
|
assert_difference [post_count, frag_count] do
|
58
|
-
r :post, comfy_admin_blog_posts_path(@site), params: {post: {
|
59
|
-
title:
|
60
|
-
slug:
|
58
|
+
r :post, comfy_admin_blog_posts_path(@site), params: { post: {
|
59
|
+
title: "Test Post",
|
60
|
+
slug: "test-post",
|
61
61
|
published_at: 2.days.ago.to_s(:db),
|
62
|
-
is_published:
|
62
|
+
is_published: "1",
|
63
63
|
layout_id: @layout,
|
64
64
|
fragments_attributes: [
|
65
|
-
{ identifier:
|
66
|
-
content:
|
65
|
+
{ identifier: "content",
|
66
|
+
content: "test text" }
|
67
67
|
]
|
68
|
-
}}
|
68
|
+
} }
|
69
69
|
assert_response :redirect
|
70
70
|
assert_redirected_to action: :edit, id: assigns(:post)
|
71
|
-
assert_equal
|
71
|
+
assert_equal "Blog Post created", flash[:success]
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
75
|
def test_creation_failure
|
76
|
-
assert_no_difference ->{Comfy::Blog::Post.count} do
|
77
|
-
r :post, comfy_admin_blog_posts_path(@site), params: {post: {}}
|
76
|
+
assert_no_difference -> { Comfy::Blog::Post.count } do
|
77
|
+
r :post, comfy_admin_blog_posts_path(@site), params: { post: {} }
|
78
78
|
assert_response :success
|
79
79
|
assert_template :new
|
80
80
|
assert assigns(:post)
|
81
|
-
assert_equal
|
81
|
+
assert_equal "Failed to create Blog Post", flash[:danger]
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -91,42 +91,63 @@ class Comfy::Admin::Blog::PostsControllerTest < ActionDispatch::IntegrationTest
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def test_get_edit_failure
|
94
|
-
r :get, edit_comfy_admin_blog_post_path(@site,
|
94
|
+
r :get, edit_comfy_admin_blog_post_path(@site, "invalid")
|
95
95
|
assert_response :redirect
|
96
96
|
assert_redirected_to action: :index
|
97
|
-
assert_equal
|
97
|
+
assert_equal "Blog Post not found", flash[:danger]
|
98
98
|
end
|
99
99
|
|
100
100
|
def test_update
|
101
|
-
r :put, comfy_admin_blog_post_path(@site, @post), params: {post: {
|
102
|
-
title:
|
103
|
-
}}
|
101
|
+
r :put, comfy_admin_blog_post_path(@site, @post), params: { post: {
|
102
|
+
title: "Updated Post"
|
103
|
+
} }
|
104
104
|
assert_response :redirect
|
105
105
|
assert_redirected_to action: :edit, id: assigns(:post)
|
106
|
-
assert_equal
|
106
|
+
assert_equal "Blog Post updated", flash[:success]
|
107
107
|
|
108
108
|
@post.reload
|
109
|
-
assert_equal
|
109
|
+
assert_equal "Updated Post", @post.title
|
110
110
|
end
|
111
111
|
|
112
112
|
def test_update_failure
|
113
|
-
r :put, comfy_admin_blog_post_path(@site, @post), params: {post: {
|
114
|
-
title:
|
115
|
-
}}
|
113
|
+
r :put, comfy_admin_blog_post_path(@site, @post), params: { post: {
|
114
|
+
title: ""
|
115
|
+
} }
|
116
116
|
assert_response :success
|
117
117
|
assert_template :edit
|
118
|
-
assert_equal
|
118
|
+
assert_equal "Failed to update Blog Post", flash[:danger]
|
119
119
|
|
120
120
|
@post.reload
|
121
|
-
assert_not_equal
|
121
|
+
assert_not_equal "", @post.title
|
122
122
|
end
|
123
123
|
|
124
124
|
def test_destroy
|
125
|
-
assert_difference -> {Comfy::Blog::Post.count}, -1 do
|
125
|
+
assert_difference -> { Comfy::Blog::Post.count }, -1 do
|
126
126
|
r :delete, comfy_admin_blog_post_path(@site, @post)
|
127
127
|
assert_response :redirect
|
128
128
|
assert_redirected_to action: :index
|
129
|
-
assert_equal
|
129
|
+
assert_equal "Blog Post removed", flash[:success]
|
130
130
|
end
|
131
131
|
end
|
132
|
+
|
133
|
+
def test_get_form_fragments
|
134
|
+
r :get, form_fragments_comfy_admin_blog_post_path(site_id: @site, id: @post), xhr: true, params: {
|
135
|
+
layout_id: @layout.id
|
136
|
+
}
|
137
|
+
assert_response :success
|
138
|
+
assert assigns(:post)
|
139
|
+
assert_equal 1, assigns(:post).fragment_nodes.size
|
140
|
+
assert_template :form_fragments
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_get_form_fragments_for_new_post
|
144
|
+
r :get, form_fragments_comfy_admin_blog_post_path(site_id: @site, id: 0), xhr: true, params: {
|
145
|
+
layout_id: @layout.id
|
146
|
+
}
|
147
|
+
assert_response :success
|
148
|
+
assert assigns(:post)
|
149
|
+
assert_equal 1, assigns(:post).fragment_nodes.size
|
150
|
+
assert_template :form_fragments
|
151
|
+
end
|
152
|
+
|
132
153
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "../../../../../test_helper"
|
2
2
|
|
3
3
|
class Comfy::Admin::Cms::Revisions::PageControllerTest < ActionDispatch::IntegrationTest
|
4
4
|
|
@@ -34,24 +34,23 @@ class Comfy::Admin::Cms::Revisions::PageControllerTest < ActionDispatch::Integra
|
|
34
34
|
r :get, comfy_admin_blog_post_revision_path(@site, "invalid", @revision)
|
35
35
|
assert_response :redirect
|
36
36
|
assert_redirected_to comfy_admin_blog_posts_path(@site)
|
37
|
-
assert_equal
|
37
|
+
assert_equal "Record Not Found", flash[:danger]
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
40
|
def test_get_show_failure
|
42
41
|
r :get, comfy_admin_blog_post_revision_path(@site, @post, "invalid")
|
43
42
|
assert_response :redirect
|
44
43
|
assert assigns(:record)
|
45
44
|
assert_redirected_to edit_comfy_admin_blog_post_path(@site, assigns(:record))
|
46
|
-
assert_equal
|
45
|
+
assert_equal "Revision Not Found", flash[:danger]
|
47
46
|
end
|
48
47
|
|
49
48
|
def test_revert
|
50
|
-
assert_difference -> {@post.revisions.count} do
|
49
|
+
assert_difference -> { @post.revisions.count } do
|
51
50
|
r :patch, revert_comfy_admin_blog_post_revision_path(@site, @post, @revision)
|
52
51
|
assert_response :redirect
|
53
52
|
assert_redirected_to edit_comfy_admin_blog_post_path(@site, @post)
|
54
|
-
assert_equal
|
53
|
+
assert_equal "Content Reverted", flash[:success]
|
55
54
|
|
56
55
|
@post.reload
|
57
56
|
|
@@ -64,4 +63,5 @@ class Comfy::Admin::Cms::Revisions::PageControllerTest < ActionDispatch::Integra
|
|
64
63
|
}], @post.fragments_attributes
|
65
64
|
end
|
66
65
|
end
|
66
|
+
|
67
67
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "../../../test_helper"
|
2
2
|
|
3
3
|
class Comfy::Blog::PostsControllerTest < ActionDispatch::IntegrationTest
|
4
4
|
|
@@ -16,7 +16,7 @@ class Comfy::Blog::PostsControllerTest < ActionDispatch::IntegrationTest
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_get_index_as_rss
|
19
|
-
get comfy_blog_posts_path, params: {format: :rss}
|
19
|
+
get comfy_blog_posts_path, params: { format: :rss }
|
20
20
|
assert_response :success
|
21
21
|
assert_template :index
|
22
22
|
assert assigns(:blog_posts)
|
@@ -52,12 +52,12 @@ class Comfy::Blog::PostsControllerTest < ActionDispatch::IntegrationTest
|
|
52
52
|
|
53
53
|
def test_get_index_with_category
|
54
54
|
category = @site.categories.create!(
|
55
|
-
label:
|
56
|
-
categorized_type:
|
55
|
+
label: "Test Category",
|
56
|
+
categorized_type: "Comfy::Blog::Post"
|
57
57
|
)
|
58
58
|
category.categorizations.create!(categorized: @post)
|
59
59
|
|
60
|
-
get comfy_blog_posts_path, params: {category: category.label}
|
60
|
+
get comfy_blog_posts_path, params: { category: category.label }
|
61
61
|
|
62
62
|
assert_response :success
|
63
63
|
assert assigns(:blog_posts)
|
@@ -66,7 +66,7 @@ class Comfy::Blog::PostsControllerTest < ActionDispatch::IntegrationTest
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def test_get_index_with_category_invalid
|
69
|
-
get comfy_blog_posts_path, params: {category:
|
69
|
+
get comfy_blog_posts_path, params: { category: "invalid" }
|
70
70
|
assert_response :success
|
71
71
|
assert assigns(:blog_posts)
|
72
72
|
assert_equal 0, assigns(:blog_posts).count
|
@@ -91,4 +91,5 @@ class Comfy::Blog::PostsControllerTest < ActionDispatch::IntegrationTest
|
|
91
91
|
get comfy_blog_post_path(@site.path, 1234, 99, @post.slug)
|
92
92
|
end
|
93
93
|
end
|
94
|
+
|
94
95
|
end
|
@@ -5,8 +5,9 @@ gemspec path: "../../"
|
|
5
5
|
gem 'kaminari', '>= 0.14.0'
|
6
6
|
|
7
7
|
group :test do
|
8
|
-
gem
|
9
|
-
gem
|
10
|
-
gem
|
11
|
-
gem
|
8
|
+
gem "rubocop", "~> 0.51.0", require: false
|
9
|
+
gem "sqlite3"
|
10
|
+
gem "coveralls", require: false
|
11
|
+
gem "mocha", require: false
|
12
|
+
gem "rails-controller-testing"
|
12
13
|
end
|
@@ -1,19 +1,20 @@
|
|
1
|
-
require_relative
|
2
|
-
require_relative
|
1
|
+
require_relative "../test_helper"
|
2
|
+
require_relative "../../lib/generators/comfy/blog/blog_generator"
|
3
3
|
|
4
4
|
class CmsGeneratorTest < Rails::Generators::TestCase
|
5
|
+
|
5
6
|
tests Comfy::Generators::BlogGenerator
|
6
7
|
|
7
8
|
def test_generator
|
8
9
|
run_generator
|
9
10
|
|
10
|
-
assert_migration
|
11
|
+
assert_migration "db/migrate/create_blog.rb"
|
11
12
|
|
12
|
-
assert_file
|
13
|
+
assert_file "config/initializers/comfy_blog.rb"
|
13
14
|
|
14
|
-
assert_file
|
15
|
+
assert_file "config/routes.rb", read_file("blog/routes.rb")
|
15
16
|
|
16
|
-
assert_directory
|
17
|
+
assert_directory "app/views/comfy/blog"
|
17
18
|
end
|
18
19
|
|
19
20
|
end
|
@@ -1,30 +1,30 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "../test_helper"
|
2
2
|
|
3
3
|
class I18nIntegrationTest < ActionDispatch::IntegrationTest
|
4
4
|
|
5
5
|
def collect_combined_keys(hash, ns = nil)
|
6
6
|
hash.collect do |k, v|
|
7
|
-
keys = [
|
7
|
+
keys = []
|
8
8
|
keys << collect_combined_keys(v, "#{ns}.#{k}") if v.is_a?(Hash)
|
9
9
|
keys << "#{ns}.#{k}"
|
10
10
|
end.flatten
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_translations
|
14
|
-
locales_path = File.expand_path(
|
14
|
+
locales_path = File.expand_path("../../../config/locales", __FILE__)
|
15
15
|
locales = Dir.glob("#{locales_path}/*.yml").collect do |file_path|
|
16
|
-
File.basename(file_path,
|
16
|
+
File.basename(file_path, ".yml")
|
17
17
|
end
|
18
18
|
|
19
19
|
# collecting all locales
|
20
|
-
locale_keys = {
|
20
|
+
locale_keys = {}
|
21
21
|
locales.each do |locale|
|
22
22
|
translations = YAML.load_file("#{locales_path}/#{locale}.yml")
|
23
23
|
locale_keys[locale] = collect_combined_keys(translations[locale])
|
24
24
|
end
|
25
25
|
|
26
26
|
# Using en as reference
|
27
|
-
reference = locale_keys[locales.delete(
|
27
|
+
reference = locale_keys[locales.delete("en")]
|
28
28
|
assert reference.present?
|
29
29
|
|
30
30
|
locale_keys.each do |locale, keys|
|
@@ -34,4 +34,5 @@ class I18nIntegrationTest < ActionDispatch::IntegrationTest
|
|
34
34
|
assert extra.blank?, "#{locale} locale has extra: #{extra.join(', ')}"
|
35
35
|
end
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
|
+
end
|
@@ -1,16 +1,17 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "../test_helper"
|
2
2
|
|
3
3
|
class ConfigurationTest < ActiveSupport::TestCase
|
4
4
|
|
5
5
|
def test_configuration
|
6
6
|
assert config = ComfyBlog.configuration
|
7
7
|
assert_equal 10, config.posts_per_page
|
8
|
-
assert_equal
|
9
|
-
assert_equal
|
8
|
+
assert_equal "comfy/blog/application", config.app_layout
|
9
|
+
assert_equal "blog", config.public_blog_path
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_initialization_overrides
|
13
13
|
ComfyBlog.config.posts_per_page = 5
|
14
14
|
assert_equal 5, ComfyBlog.config.posts_per_page
|
15
15
|
end
|
16
|
+
|
16
17
|
end
|
data/test/models/posts_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "../test_helper"
|
2
2
|
|
3
3
|
class BlogPostsTest < ActiveSupport::TestCase
|
4
4
|
|
@@ -35,29 +35,29 @@ class BlogPostsTest < ActiveSupport::TestCase
|
|
35
35
|
|
36
36
|
def test_validation_of_slug_format
|
37
37
|
post = @site.blog_posts.new(
|
38
|
-
title:
|
39
|
-
slug:
|
38
|
+
title: "Test Title",
|
39
|
+
slug: "test%slug",
|
40
40
|
layout: @layout
|
41
41
|
)
|
42
42
|
assert post.valid?
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_creation
|
46
|
-
assert_difference -> {Comfy::Blog::Post.count} do
|
46
|
+
assert_difference -> { Comfy::Blog::Post.count } do
|
47
47
|
post = @site.blog_posts.create!(
|
48
|
-
title:
|
48
|
+
title: "Test Post",
|
49
49
|
layout: @layout
|
50
50
|
)
|
51
|
-
assert_equal
|
51
|
+
assert_equal "test-post", post.slug
|
52
52
|
assert_equal Time.zone.now.year, post.year
|
53
53
|
assert_equal Time.zone.now.month, post.month
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
def test_set_slug
|
58
|
-
post = Comfy::Blog::Post.new(title:
|
58
|
+
post = Comfy::Blog::Post.new(title: "Test Title")
|
59
59
|
post.send(:set_slug)
|
60
|
-
assert_equal
|
60
|
+
assert_equal "test-title", post.slug
|
61
61
|
end
|
62
62
|
|
63
63
|
def test_set_date
|
@@ -93,10 +93,11 @@ class BlogPostsTest < ActiveSupport::TestCase
|
|
93
93
|
end
|
94
94
|
|
95
95
|
def test_url
|
96
|
-
assert_equal
|
97
|
-
assert_equal
|
96
|
+
assert_equal "//test.host/blog/2012/1/default-title", @post.url
|
97
|
+
assert_equal "/blog/2012/1/default-title", @post.url(relative: true)
|
98
98
|
|
99
99
|
ComfyBlog.config.public_blog_path = "test-blog"
|
100
|
-
assert_equal
|
100
|
+
assert_equal "//test.host/test-blog/2012/1/default-title", @post.url
|
101
101
|
end
|
102
|
+
|
102
103
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
ENV[
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "simplecov"
|
4
|
+
require "coveralls"
|
5
5
|
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
6
6
|
SimpleCov.start do
|
7
|
-
add_filter
|
8
|
-
add_filter
|
7
|
+
add_filter "lib/generators"
|
8
|
+
add_filter "lib/comfy_blog/engine.rb "
|
9
9
|
end
|
10
|
-
require_relative
|
10
|
+
require_relative "../config/environment"
|
11
11
|
|
12
|
-
require
|
13
|
-
require
|
12
|
+
require "rails/test_help"
|
13
|
+
require "rails/generators"
|
14
14
|
|
15
15
|
Rails.backtrace_cleaner.remove_silencers!
|
16
16
|
|
@@ -23,8 +23,8 @@ class ActiveSupport::TestCase
|
|
23
23
|
def reset_config
|
24
24
|
ComfyBlog.configure do |config|
|
25
25
|
config.posts_per_page = 10
|
26
|
-
config.app_layout =
|
27
|
-
config.public_blog_path =
|
26
|
+
config.app_layout = "comfy/blog/application"
|
27
|
+
config.public_blog_path = "blog"
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -41,10 +41,11 @@ class ActiveSupport::TestCase
|
|
41
41
|
# assert_exception_raised do ... end
|
42
42
|
# assert_exception_raised ActiveRecord::RecordInvalid do ... end
|
43
43
|
# assert_exception_raised Plugin::Error, 'error_message' do ... end
|
44
|
-
def assert_exception_raised(exception_class = nil, error_message = nil
|
44
|
+
def assert_exception_raised(exception_class = nil, error_message = nil)
|
45
45
|
exception_raised = nil
|
46
46
|
yield
|
47
|
-
rescue => exception_raised
|
47
|
+
rescue StandardError => exception_raised
|
48
|
+
exception_raised
|
48
49
|
ensure
|
49
50
|
if exception_raised
|
50
51
|
if exception_class
|
@@ -54,7 +55,7 @@ class ActiveSupport::TestCase
|
|
54
55
|
end
|
55
56
|
assert_equal error_message, exception_raised.to_s if error_message
|
56
57
|
else
|
57
|
-
flunk
|
58
|
+
flunk "Exception was not raised"
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
@@ -65,35 +66,36 @@ class ActionDispatch::IntegrationTest
|
|
65
66
|
setup :setup_host
|
66
67
|
|
67
68
|
def setup_host
|
68
|
-
host!
|
69
|
+
host! "test.host"
|
69
70
|
end
|
70
71
|
|
71
72
|
# Attaching http_auth stuff with request. Example use:
|
72
73
|
# r :get, '/cms-admin/pages'
|
73
74
|
def r(method, path, options = {})
|
74
75
|
headers = options[:headers] || {}
|
75
|
-
headers[
|
76
|
+
headers["HTTP_AUTHORIZATION"] = ActionController::HttpAuthentication::Basic.encode_credentials(
|
76
77
|
ComfortableMexicanSofa::AccessControl::AdminAuthentication.username,
|
77
78
|
ComfortableMexicanSofa::AccessControl::AdminAuthentication.password
|
78
79
|
)
|
79
|
-
options
|
80
|
+
options[:headers] = headers
|
80
81
|
send(method, path, options)
|
81
82
|
end
|
83
|
+
|
82
84
|
end
|
83
85
|
|
84
86
|
class Rails::Generators::TestCase
|
85
87
|
|
86
|
-
destination File.expand_path(
|
88
|
+
destination File.expand_path("../tmp", File.dirname(__FILE__))
|
87
89
|
|
88
90
|
setup :prepare_destination,
|
89
91
|
:prepare_files
|
90
92
|
|
91
93
|
def prepare_files
|
92
|
-
config_path = File.join(
|
93
|
-
routes_path = File.join(config_path,
|
94
|
+
config_path = File.join(destination_root, "config")
|
95
|
+
routes_path = File.join(config_path, "routes.rb")
|
94
96
|
FileUtils.mkdir_p(config_path)
|
95
97
|
FileUtils.touch(routes_path)
|
96
|
-
File.open(routes_path,
|
98
|
+
File.open(routes_path, "w") do |f|
|
97
99
|
f.write("Test::Application.routes.draw do\n\nend")
|
98
100
|
end
|
99
101
|
end
|
@@ -101,9 +103,10 @@ class Rails::Generators::TestCase
|
|
101
103
|
def read_file(filename)
|
102
104
|
File.read(
|
103
105
|
File.join(
|
104
|
-
File.expand_path(
|
106
|
+
File.expand_path("fixtures/generators", File.dirname(__FILE__)),
|
105
107
|
filename
|
106
108
|
)
|
107
109
|
)
|
108
110
|
end
|
111
|
+
|
109
112
|
end
|