-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #38 Make backward compatible with Rails 4.2.
Increase test coverage.
- Loading branch information
1 parent
6d25a89
commit ca16392
Showing
38 changed files
with
391 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
.DS_Store | ||
.bundle/ | ||
*.log | ||
pkg/ | ||
test/dummy/tmp/ | ||
test/dummy/.sass-cache | ||
*.gem | ||
.idea/* | ||
/.idea | ||
tags | ||
*.DS_Store | ||
Gemfile.lock | ||
._test | ||
*.log | ||
/gemfiles/*.lock | ||
|
||
*.lock | ||
*.sqlite3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
## Installation | ||
|
||
Install all needed gems to run the tests: | ||
|
||
appraisal install | ||
|
||
The gems are installed into the global gem list. | ||
The Gemfiles in the `gemfiles` folder are also re-generated. | ||
|
||
## Run Tests | ||
|
||
For all supported Rails/ActiveRecord versions: | ||
|
||
rake | ||
|
||
Or for specific rails version: | ||
|
||
appraisal rails_4.2 rake | ||
|
||
Or for one particular test file: | ||
|
||
appraisal rails_5.0 ruby test/controllers/articles_controller_test.rb | ||
|
||
Or down to one test case: | ||
|
||
appraisal rails_5.0 ruby test/controllers/articles_controller_test.rb -n "/shows new article/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module RailsSemanticLogger #:nodoc | ||
VERSION = '4.1.0' | ||
VERSION = '4.1.1' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
require_relative "../test_helper" | ||
|
||
class ArticlesControllerTest < ActionController::TestCase | ||
describe ArticlesController do | ||
before do | ||
# Use a mock logger that just keeps the last logged entry in an instance variable | ||
SemanticLogger.default_level = :trace | ||
SemanticLogger.backtrace_level = nil | ||
@mock_logger = MockLogger.new | ||
@appender = SemanticLogger.add_appender(logger: @mock_logger, formatter: :raw) | ||
@logger = SemanticLogger['Test'] | ||
@hash = {session_id: 'HSSKLEU@JDK767', tracking_number: 12345} | ||
|
||
assert_equal [], SemanticLogger.tags | ||
assert_equal 65535, SemanticLogger.backtrace_level_index | ||
end | ||
|
||
after do | ||
SemanticLogger.remove_appender(@appender) | ||
end | ||
|
||
describe 'GET #new' do | ||
it 'shows new article' do | ||
get :new | ||
assert_response :success | ||
end | ||
end | ||
|
||
describe 'POST #create' do | ||
describe 'with valid parameters' do | ||
let(:params) do | ||
{ | ||
article: { | ||
text: 'Text1', | ||
title: 'Title1' | ||
} | ||
} | ||
end | ||
|
||
before do | ||
params = {params: self.params} if Rails.version.to_i >= 5 | ||
post :create, params | ||
end | ||
|
||
it 'has no errors' do | ||
assert_response :success | ||
end | ||
|
||
it 'successfully logs message' do | ||
SemanticLogger.flush | ||
actual = @mock_logger.message | ||
|
||
assert_equal 'Completed #create', actual[:message] | ||
assert_equal 'ArticlesController', actual[:name] | ||
|
||
assert payload = actual[:payload], actual | ||
assert_equal 'create', payload[:action], payload | ||
assert_equal 'ArticlesController', payload[:controller], payload | ||
assert_equal 'HTML', payload[:format], payload | ||
assert_equal 'POST', payload[:method], payload | ||
# Only Rails 5 passes the arguments through | ||
if Rails.version.to_i >= 5 | ||
assert_equal({"article" => {"text" => "Text1", "title" => "Title1"}}, payload[:params], payload) | ||
end | ||
assert_equal '/articles', payload[:path], payload | ||
assert_equal 200, payload[:status], payload | ||
assert_equal 'OK', payload[:status_message], payload | ||
assert (payload[:view_runtime] >= 0.0), payload | ||
assert (payload[:db_runtime] >= 0.0), payload | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require_relative '../test_helper' | ||
|
||
class WelcomeControllerTest < ActionController::TestCase | ||
describe WelcomeController do | ||
before do | ||
get :index | ||
end | ||
|
||
it 'should get index' do | ||
assert_response :success | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Place all the behaviors and hooks related to the matching controller here. | ||
// All this logic will automatically be available in application.js. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* | ||
Place all the styles related to the matching controller here. | ||
They will automatically be included in application.css. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* | ||
Place all the styles related to the matching controller here. | ||
They will automatically be included in application.css. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
class ApplicationController < ActionController::Base | ||
protect_from_forgery | ||
protect_from_forgery with: :exception | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class ArticlesController < ApplicationController | ||
def new | ||
end | ||
|
||
def create | ||
render plain: params[:article].inspect | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class WelcomeController < ApplicationController | ||
def index | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module ArticlesHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module WelcomeHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<h1>New Article</h1> | ||
|
||
<%= form_for :article, url: articles_path do |f| %> | ||
<p> | ||
<%= f.label :title %><br> | ||
<%= f.text_field :title %> | ||
</p> | ||
|
||
<p> | ||
<%= f.label :text %><br> | ||
<%= f.text_area :text %> | ||
</p> | ||
|
||
<p> | ||
<%= f.submit %> | ||
</p> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<h1>Welcome#index</h1> | ||
<p>Find me in app/views/welcome/index.html.erb</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env ruby | ||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) | ||
load Gem.bin_path('bundler', 'bundle') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env ruby | ||
# | ||
# This file was generated by Bundler. | ||
# | ||
# The application 'puma' is installed as part of a gem, and | ||
# this file is here to facilitate running it. | ||
# | ||
|
||
require 'pathname' | ||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', Pathname.new(__FILE__).realpath) | ||
|
||
require 'rubygems' | ||
require 'bundler/setup' | ||
|
||
load Gem.bin_path('puma', 'puma') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env ruby | ||
APP_PATH = File.expand_path('../../config/application', __FILE__) | ||
require_relative '../config/boot' | ||
require 'rails/commands' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env ruby | ||
require_relative '../config/boot' | ||
require 'rake' | ||
Rake.application.run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env ruby | ||
require 'pathname' | ||
|
||
# path to your application root. | ||
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) | ||
|
||
Dir.chdir APP_ROOT do | ||
# This script is a starting point to setup your application. | ||
# Add necessary setup steps to this file: | ||
|
||
puts "== Installing dependencies ==" | ||
system "gem install bundler --conservative" | ||
system "bundle check || bundle install" | ||
|
||
# puts "\n== Copying sample files ==" | ||
# unless File.exist?("config/database.yml") | ||
# system "cp config/database.yml.sample config/database.yml" | ||
# end | ||
|
||
puts "\n== Removing old logs and tempfiles ==" | ||
system "rm -f log/*" | ||
system "rm -rf tmp/cache" | ||
|
||
puts "\n== Restarting application server ==" | ||
system "touch tmp/restart.txt" | ||
end |
Oops, something went wrong.