Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates version 1 to work with rails 5.2 #81

Open
wants to merge 6 commits into
base: 1.12
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,18 @@ before_script:
script:
- rake ci
rvm:
- 1.9.3
- 2.0.0
- 2.1.5
- 2.2.0
- 2.2.2
- 2.4.1
- 2.5.1
gemfile:
- test/gemfiles/Gemfile.rails.4.0
- test/gemfiles/Gemfile.rails.4.1
- test/gemfiles/Gemfile.rails.4.2
- test/gemfiles/Gemfile.rails.5.2
branches:
only:
- master
matrix:
fast_finish: true
include:
- rvm: 2.2.0
- rvm: 2.4.1
gemfile: test/gemfiles/Gemfile.rails.master
allow_failures:
- gemfile: test/gemfiles/Gemfile.rails.master
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ group :development do
gem 'awesome_print'
gem 'better_errors'
gem 'binding_of_caller'
gem 'quiet_assets'
end

group :test do
gem 'sqlite3'
gem 'coveralls', :require => false
gem 'rails-controller-testing'
end
2 changes: 1 addition & 1 deletion app/models/comfy/blog/blog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Comfy::Blog::Blog < ActiveRecord::Base
:uniqueness => { :scope => :site_id },
:format => { :with => /\A\w[a-z0-9_-]*\z/i },
:presence => true,
:if => 'restricted_path?'
:if => :restricted_path?

protected

Expand Down
2 changes: 1 addition & 1 deletion app/views/comfy/admin/blog/blogs/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
= form.text_field :identifier, :data => {:slug => true}
= form.text_field :path

- if (options = Comfy::Cms::Layout.app_layouts_for_select).present?
- if (options = Comfy::Cms::Layout.app_layouts_for_select(lookup_context.view_paths)).present?
= form.select :app_layout, options

= form.text_area :description, :class => 'short'
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/00_create_cms.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateCms < ActiveRecord::Migration
class CreateCms < ActiveRecord::Migration[4.2]

def self.up

Expand Down
2 changes: 1 addition & 1 deletion db/migrate/01_create_blog.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateBlog < ActiveRecord::Migration
class CreateBlog < ActiveRecord::Migration[4.2]

def self.up
create_table :comfy_blogs do |t|
Expand Down
2 changes: 1 addition & 1 deletion lib/comfy_blog/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ComfyBlog
VERSION = "1.12.3"
VERSION = "1.13.0"
end
2 changes: 1 addition & 1 deletion lib/generators/comfy/blog/blog_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def generate_initialization

def generate_routing
route_string = " comfy_route :blog_admin, :path => '/admin'\n"
route_string << " comfy_route :blog, :path => '/blog'\n"
route_string << "comfy_route :blog, :path => '/blog'\n\n"
route route_string[2..-1]
end

Expand Down
24 changes: 12 additions & 12 deletions test/controllers/comfy/admin/blog/blogs_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,43 @@ def setup
end

def test_get_index
get :index, :site_id => @site
get :index, params: { :site_id => @site }
assert_response :success
assert assigns(:blogs)
assert_template :index
end

def test_get_new
get :new, :site_id => @site
get :new, params: { :site_id => @site }
assert_response :success
assert assigns(:blog)
assert_template :new
assert_select "form[action='/admin/sites/#{@site.id}/blogs']"
end

def test_get_edit
get :edit, :site_id => @site, :id => @blog
get :edit, params: { :site_id => @site, :id => @blog }
assert_response :success
assert assigns(:blog)
assert_template :edit
assert_select "form[action='/admin/sites/#{@site.id}/blogs/#{@blog.id}']"
end

def test_get_edit_failure
get :edit, :site_id => @site, :id => 'invalid'
get :edit, params: { :site_id => @site, :id => 'invalid' }
assert_response :redirect
assert_redirected_to :action => :index
assert_equal 'Blog not found', flash[:error]
end

def test_creation
assert_difference 'Comfy::Blog::Blog.count' do
post :create, :site_id => @site, :blog => {
post :create, params: { :site_id => @site, :blog => {
:label => 'Test Blog',
:identifier => 'test-blog',
:path => 'test-blog',
:description => 'Test Description'
}
}}
blog = Comfy::Blog::Blog.last
assert_response :redirect
assert_redirected_to :action => :edit, :id => blog
Expand All @@ -54,17 +54,17 @@ def test_creation

def test_creation_failure
assert_no_difference 'Comfy::Blog::Blog.count' do
post :create, :site_id => @site, :blog => { }
post :create, params: { :site_id => @site, :blog => { } }
assert_response :success
assert_template :new
assert_equal 'Failed to create Blog', flash[:error]
end
end

def test_update
put :update, :site_id => @site, :id => @blog, blog: {
put :update, params: { :site_id => @site, :id => @blog, blog: {
:label => 'Updated'
}
}}
assert_response :redirect
assert_redirected_to :action => :edit, :id => @blog
assert_equal 'Blog updated', flash[:success]
Expand All @@ -73,9 +73,9 @@ def test_update
end

def test_update_failure
put :update, :site_id => @site, :id => @blog, :blog => {
put :update, params: { :site_id => @site, :id => @blog, :blog => {
:label => ''
}
}}
assert_response :success
assert_template :edit
assert_equal 'Failed to update Blog', flash[:error]
Expand All @@ -85,7 +85,7 @@ def test_update_failure

def test_destroy
assert_difference 'Comfy::Blog::Blog.count', -1 do
delete :destroy, :site_id => @site, :id => @blog
delete :destroy, params: { :site_id => @site, :id => @blog }
assert_response :redirect
assert_redirected_to :action => :index
assert_equal 'Blog deleted', flash[:success]
Expand Down
12 changes: 6 additions & 6 deletions test/controllers/comfy/admin/blog/comments_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ def setup
end

def test_get_index
get :index, :site_id => @site, :blog_id => @blog
get :index, params: { :site_id => @site, :blog_id => @blog }
assert_response :success
assert_template :index
assert assigns(:comments)
assert !assigns(:post)
end

def test_get_index_for_post
get :index, :site_id => @site, :blog_id => @blog, :post_id => @post
get :index, params: { :site_id => @site, :blog_id => @blog, :post_id => @post }
assert_response :success
assert_template :index
assert assigns(:post)
Expand All @@ -27,28 +27,28 @@ def test_get_index_for_post

def test_publish
assert @comment.is_published?
xhr :patch, :toggle_publish, :site_id => @site, :blog_id => @blog, :id => @comment
patch :toggle_publish, params: { :site_id => @site, :blog_id => @blog, :id => @comment }, xhr: true
assert_response :success
@comment.reload
assert [email protected]_published?

xhr :patch, :toggle_publish, :site_id => @site, :blog_id => @blog, :id => @comment
patch :toggle_publish, params: { :site_id => @site, :blog_id => @blog, :id => @comment }, xhr: true
assert_response :success
@comment.reload
assert @comment.is_published?
end

def test_destroy
assert_difference 'Comfy::Blog::Comment.count', -1 do
delete :destroy, :site_id => @site, :blog_id => @blog, :id => @comment
delete :destroy, params: { :site_id => @site, :blog_id => @blog, :id => @comment }
assert_response :redirect
assert_redirected_to :action => :index
assert_equal 'Comment deleted', flash[:success]
end
end

def test_destroy_failure
delete :destroy, :site_id => @site, :blog_id => @blog, :id => 'invalid'
delete :destroy, params: { :site_id => @site, :blog_id => @blog, :id => 'invalid' }
assert_response :redirect
assert_redirected_to :action => :index
assert_equal 'Comment not found', flash[:error]
Expand Down
26 changes: 13 additions & 13 deletions test/controllers/comfy/admin/blog/posts_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ def setup
end

def test_get_index
get :index, :site_id => @site, :blog_id => @blog
get :index, params: { :site_id => @site, :blog_id => @blog }
assert_response :success
assert assigns(:posts)
assert_template :index
end

def test_get_new
get :new, :site_id => @site, :blog_id => @blog
get :new, params: { :site_id => @site, :blog_id => @blog }
assert_response :success
assert assigns(:post)
assert_template :new
Expand All @@ -25,22 +25,22 @@ def test_get_new

def test_get_new_with_default_author
ComfyBlog.config.default_author = 'Default Author'
get :new, :site_id => @site, :blog_id => @blog
get :new, params: { :site_id => @site, :blog_id => @blog }
assert_response :success
assert assigns(:post)
assert_equal 'Default Author', assigns(:post).author
end

def test_creation
assert_difference 'Comfy::Blog::Post.count' do
post :create, :site_id => @site, :blog_id => @blog, :post => {
post :create, params: { :site_id => @site, :blog_id => @blog, :post => {
:title => 'Test Post',
:slug => 'test-post',
:content => 'Test Content',
:excerpt => 'Test Excerpt',
:published_at => 2.days.ago.to_s(:db),
:is_published => '1'
}
}}
assert_response :redirect
assert_redirected_to :action => :edit, :id => assigns(:post)
assert_equal 'Blog Post created', flash[:success]
Expand All @@ -49,7 +49,7 @@ def test_creation

def test_creation_failure
assert_no_difference 'Comfy::Blog::Post.count' do
post :create, :site_id => @site, :blog_id => @blog, :post => { }
post :create, params: { :site_id => @site, :blog_id => @blog, :post => { } }
assert_response :success
assert_template :new
assert assigns(:post)
Expand All @@ -58,24 +58,24 @@ def test_creation_failure
end

def test_get_edit
get :edit, :site_id => @site, :blog_id => @blog, :id => @post
get :edit, params: { :site_id => @site, :blog_id => @blog, :id => @post }
assert_response :success
assert_template :edit
assert assigns(:post)
assert_select "form[action='/admin/sites/#{@site.id}/blogs/#{@blog.id}/posts/#{@post.id}']"
end

def test_get_edit_failure
get :edit, :site_id => @site, :blog_id => @blog, :id => 'invalid'
get :edit, params: { :site_id => @site, :blog_id => @blog, :id => 'invalid' }
assert_response :redirect
assert_redirected_to :action => :index
assert_equal 'Blog Post not found', flash[:error]
end

def test_update
put :update, :site_id => @site, :blog_id => @blog, :id => @post, :post => {
put :update, params: { :site_id => @site, :blog_id => @blog, :id => @post, :post => {
:title => 'Updated Post'
}
}}
assert_response :redirect
assert_redirected_to :action => :edit, :id => assigns(:post)
assert_equal 'Blog Post updated', flash[:success]
Expand All @@ -85,9 +85,9 @@ def test_update
end

def test_update_failure
put :update, :site_id => @site, :blog_id => @blog, :id => @post, :post => {
put :update, params: { :site_id => @site, :blog_id => @blog, :id => @post, :post => {
:title => ''
}
}}
assert_response :success
assert_template :edit
assert_equal 'Failed to update Blog Post', flash[:error]
Expand All @@ -98,7 +98,7 @@ def test_update_failure

def test_destroy
assert_difference 'Comfy::Blog::Post.count', -1 do
delete :destroy, :site_id => @site, :blog_id => @blog, :id => @post
delete :destroy, params: { :site_id => @site, :blog_id => @blog, :id => @post }
assert_response :redirect
assert_redirected_to :action => :index
assert_equal 'Blog Post removed', flash[:success]
Expand Down
6 changes: 3 additions & 3 deletions test/controllers/comfy/blog/comments_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ def setup

def test_creation
assert_difference 'Comfy::Blog::Comment.count' do
post :create, :slug => @post.slug, :comment => {
post :create, params: { :slug => @post.slug, :comment => {
:author => 'Test',
:email => '[email protected]',
:content => 'Test Content'
}
}}
assert_response :redirect
assert_redirected_to comfy_blog_post_path
assert_equal 'Comment created', flash[:success]
Expand All @@ -26,7 +26,7 @@ def test_creation

def test_creation_failure
assert_no_difference 'Comfy::Blog::Comment.count' do
post :create, :slug => @post.slug, :comment => { }
post :create, params: { :slug => @post.slug, :comment => { } }
assert_response :success
assert_template :show
assert_equal 'Failed to create Comment', flash[:error]
Expand Down
Loading