Skip to content

Commit

Permalink
Updated project and tests for compatibility for Rails 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Desone Burns II committed Oct 29, 2018
1 parent e43f8e2 commit 3ce06e6
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 119 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ gem 'coffee-rails', '~> 4.2.2'
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
gem "minitest"
gem "minitest-rails", "~> 3.0.0"
gem "minitest-reporters"
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Petergate](https://github.com/elorest/petergate/blob/master/dummy/public/petergate.png)](https://github.com/elorest/petergate)

[![Build Status](https://travis-ci.org/elorest/petergate.svg)](https://travis-ci.org/elorest/petergate)
[![Build Status](https://travis-ci.org/elorest/petergate.svg)](https://travis-ci.org/dburnsii/petergate)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/isaacsloan/petergate?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Gem Version](https://badge.fury.io/rb/petergate.svg)](http://badge.fury.io/rb/petergate)

Expand Down
1 change: 1 addition & 0 deletions dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ class Application < Rails::Application
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
config.active_record.sqlite3.represent_boolean_as_integer = true
end
end
2 changes: 1 addition & 1 deletion dummy/db/migrate/20141117063228_create_blogs.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateBlogs < ActiveRecord::Migration
class CreateBlogs < ActiveRecord::Migration[5.2]
def change
create_table :blogs do |t|
t.string :title
Expand Down
2 changes: 1 addition & 1 deletion dummy/db/migrate/20141117064643_devise_create_users.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class DeviseCreateUsers < ActiveRecord::Migration
class DeviseCreateUsers < ActiveRecord::Migration[5.2]
def change
create_table(:users) do |t|
## Database authenticatable
Expand Down
2 changes: 1 addition & 1 deletion dummy/db/migrate/20141117064807_add_roles_to_users.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddRolesToUsers < ActiveRecord::Migration
class AddRolesToUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :roles, :string
end
Expand Down
38 changes: 18 additions & 20 deletions dummy/db/schema.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
Expand All @@ -11,32 +10,31 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20141117064807) do
ActiveRecord::Schema.define(version: 2014_11_17_064807) do

create_table "blogs", force: true do |t|
t.string "title"
t.text "content"
t.datetime "created_at"
t.datetime "updated_at"
create_table "blogs", force: :cascade do |t|
t.string "title"
t.text "content"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "users", force: true do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.datetime "created_at"
t.datetime "updated_at"
t.string "roles"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "roles"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end

add_index "users", ["email"], name: "index_users_on_email", unique: true
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true

end
84 changes: 42 additions & 42 deletions dummy/test/controllers/blogs_multiple_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,42 @@
let(:blog) { blogs :one }

it "gets index" do
get :index
get root_path
assert_response :success
assert_not_nil assigns(:blogs)
assert_not_nil :blog
end

it "gets new" do
get :new
get new_blog_path
assert_response :success
end

it "creates blog" do
assert_difference('Blog.count') do
post :create, blog: { content: blog.content, title: blog.title }
post blogs_path, params: { blog: { content: blog.content, title: blog.title } }
end

assert_redirected_to blog_path(assigns(:blog))
assert_redirected_to blog_path(Blog.last)
end

it "shows blog" do
get :show, id: blog
get blog_path(blog)
assert_response :success
end

it "gets edit" do
get :edit, id: blog
get edit_blog_path(blog)
assert_response :success
end

it "updates blog" do
put :update, id: blog, blog: { content: blog.content, title: blog.title }
assert_redirected_to blog_path(assigns(:blog))
put blog_path(blog), params: { blog: { content: blog.content, title: blog.title } }
assert_redirected_to blog_path(blog)
end

it "destroys blog" do
assert_difference('Blog.count', -1) do
delete :destroy, id: blog
delete blog_path(blog)
end

assert_redirected_to blogs_path
Expand All @@ -66,60 +66,60 @@
let(:blog) { blogs :one }

it "plain user can see index" do
get :index
get root_path
assert_response :success
assert_not_nil assigns(:blogs)
assert_not_nil blog
end

it "gets permission denied on new" do
get :new
get new_blog_path
assert_response 302
flash[:notice].must_equal "Permission Denied"
end

it "gets forbidden and no redirect with json format on new" do
assert_webservice_is_forbiddden do |format|
get :new, format: format
get new_blog_path, headers: { 'Accept': Mime::Type.lookup_by_extension(format).to_s, 'Content-Type': Mime::Type.lookup_by_extension(format).to_s }
end
end

it "doesn't allow plain user to create blog post" do
assert_no_difference('Blog.count') do
post :create, blog: { content: blog.content, title: blog.title }
post blogs_path, params: { blog: { content: blog.content, title: blog.title } }
assert_redirected_to root_path

assert_webservice_is_forbiddden do |format|
post :create, format: format, blog: { content: blog.content, title: blog.title }
post blogs_path, params: { blog: { 'content': blog.content, 'title': blog.title } }.to_json, headers: { 'Accept': Mime::Type.lookup_by_extension(format).to_s, 'Content-Type': Mime::Type.lookup_by_extension(format).to_s}
end
end
end

it "can see show blog" do
get :show, id: blog
get blog_path(blog)
assert_response :success
end

it "can't get to edit page" do
get :edit, id: blog
get edit_blog_path(blog)
assert_response 302
end

it "can't update blog" do
put :update, id: blog, blog: { content: blog.content, title: blog.title }
put blog_path(blog), params: { blog: { content: blog.content, title: blog.title } }
assert_redirected_to root_path

assert_webservice_is_forbiddden do |format|
put :update, format: format, id: blog, blog: { content: blog.content, title: blog.title }
put blog_path(blog), params: {blog: { content: blog.content, title: blog.title }}.to_json , headers: { 'Accept': Mime::Type.lookup_by_extension(format).to_s, 'Content-Type': Mime::Type.lookup_by_extension(format).to_s }
end
end

it "can't destroy blog" do
assert_no_difference('Blog.count') do
delete :destroy, id: blog
delete blog_path(blog)
assert_redirected_to root_path
end
assert_webservice_is_forbiddden do |format|
delete :destroy, format: format, id: blog
delete blog_path(blog), headers: { 'Accept': Mime::Type.lookup_by_extension(format).to_s, 'Content-Type': Mime::Type.lookup_by_extension(format).to_s }
end
end
end
Expand All @@ -131,47 +131,47 @@
let(:blog) { blogs :one }

it "guest can see index" do
get :index
get root_path
assert_response :success
assert_not_nil assigns(:blogs)
assert_not_nil blog
end

it "gets permission denied on new" do
get :new
assert_response 302
get new_blog_path
assert_redirected_to "/users/sign_in"
end

it "json gets permission denied on new" do
assert_webservice_is_unauthorized do |format|
get :new, format: format
get new_blog_path, headers: {'Accept': Mime::Type.lookup_by_extension(format).to_s, 'Content-Type': Mime::Type.lookup_by_extension(format).to_s}
end
end

it "doesn't allow plain user to create blog post" do
assert_no_difference('Blog.count') do
post :create, blog: { content: blog.content, title: blog.title }
post blogs_path, params: { blog: { content: blog.content, title: blog.title } }
assert_redirected_to "/users/sign_in"
end
end

it "doesn't show blog" do
get :show, id: blog
get blog_path(blog)
assert_response 302
end

it "can't get to edit page" do
get :edit, id: blog
get edit_blog_path(blog)
assert_response 302
end

it "can't update blog" do
put :update, id: blog, blog: { content: blog.content, title: blog.title }
put blog_path(blog), params: { blog: { content: blog.content, title: blog.title } }
assert_redirected_to "/users/sign_in"
end

it "can't destroy blog" do
assert_no_difference('Blog.count') do
delete :destroy, id: blog
delete blog_path(blog)
assert_redirected_to "/users/sign_in"
end
end
Expand All @@ -189,42 +189,42 @@
let(:blog) { blogs :one }

it "gets index" do
get :index
get root_path
assert_response :success
assert_not_nil assigns(:blogs)
assert_not_nil :blogs
end

it "gets new" do
get :new
get new_blog_path
assert_response :success
end

it "creates blog" do
assert_difference('Blog.count') do
post :create, blog: { content: blog.content, title: blog.title }
post blogs_path, params: { blog: { content: blog.content, title: blog.title } }
end

assert_redirected_to blog_path(assigns(:blog))
assert_redirected_to blog_path(Blog.last)
end

it "shows blog" do
get :show, id: blog
get blog_path(blog)
assert_response :success
end

it "gets edit" do
get :edit, id: blog
get edit_blog_path(blog)
assert_response :success
end

it "updates blog" do
put :update, id: blog, blog: { content: blog.content, title: blog.title }
assert_redirected_to blog_path(assigns(:blog))
put blog_path(blog), params: { blog: { content: blog.content, title: blog.title } }
assert_redirected_to blog_path(blog)
end

it "can't destroy blog" do
assert_no_difference('Blog.count', -1) do
delete :destroy, id: blog
delete blog_path(id: blog)
end

assert_redirected_to root_path
Expand Down
Loading

0 comments on commit 3ce06e6

Please sign in to comment.