-
Notifications
You must be signed in to change notification settings - Fork 900
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #684 from airblade/install_appraisal
Begin testing against AR 5
- Loading branch information
Showing
15 changed files
with
241 additions
and
124 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,3 +1,4 @@ | ||
gemfiles/*.lock | ||
NOTES | ||
test/debug.log | ||
test/paper_trail_plugin.sqlite3.db | ||
|
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,45 @@ | ||
# Specify here only version constraints that differ from | ||
# `paper_trail.gemspec`. | ||
# | ||
# > The dependencies in your Appraisals file are combined with dependencies in | ||
# > your Gemfile, so you don"t need to repeat anything that"s the same for each | ||
# > appraisal. If something is specified in both the Gemfile and an appraisal, | ||
# > the version from the appraisal takes precedence. | ||
# > https://github.com/thoughtbot/appraisal | ||
|
||
appraise "ar3" do | ||
gem "activerecord", "~> 3.2" | ||
gem "i18n", "~> 0.6.11" | ||
gem "request_store", "~> 1.1.0" | ||
|
||
group :development, :test do | ||
gem 'railties', '~> 3.0' | ||
gem 'test-unit', '~> 3.0' | ||
platforms :ruby do | ||
gem 'mysql2', '~> 0.3.20' | ||
gem 'pg', '~> 0.17.1' | ||
end | ||
platforms :jruby do | ||
gem 'activerecord-jdbcsqlite3-adapter', '~> 1.3' | ||
gem 'activerecord-jdbcpostgresql-adapter', '~> 1.3' | ||
gem 'activerecord-jdbcmysql-adapter', '~> 1.3' | ||
gem 'activerecord-jdbc-adapter', '1.3.15' | ||
end | ||
end | ||
end | ||
|
||
appraise "ar4" do | ||
gem "activerecord", "~> 4.2" | ||
end | ||
|
||
appraise "ar5" do | ||
gem "activerecord", "5.0.0.beta1" | ||
gem "activemodel", "5.0.0.beta1" | ||
gem "actionpack", "5.0.0.beta1" | ||
gem "railties", "5.0.0.beta1" | ||
gem "rspec-rails", github: "rspec/rspec-rails" | ||
gem "rspec-core", github: "rspec/rspec-core" | ||
gem "rspec-expectations", github: "rspec/rspec-expectations" | ||
gem "rspec-mocks", github: "rspec/rspec-mocks" | ||
gem "rspec-support", github: "rspec/rspec-support" | ||
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 was deleted.
Oops, something went wrong.
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 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "https://rubygems.org" | ||
|
||
gem "activerecord", "~> 3.2" | ||
gem "i18n", "~> 0.6.11" | ||
gem "request_store", "~> 1.1.0" | ||
|
||
group :development, :test do | ||
gem "railties", "~> 3.0" | ||
gem "test-unit", "~> 3.0" | ||
|
||
platforms :ruby do | ||
gem "mysql2", "~> 0.3.20" | ||
gem "pg", "~> 0.17.1" | ||
end | ||
|
||
platforms :jruby do | ||
gem "activerecord-jdbcsqlite3-adapter", "~> 1.3" | ||
gem "activerecord-jdbcpostgresql-adapter", "~> 1.3" | ||
gem "activerecord-jdbcmysql-adapter", "~> 1.3" | ||
gem "activerecord-jdbc-adapter", "1.3.15" | ||
end | ||
end | ||
|
||
gemspec :path => "../" |
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,7 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "https://rubygems.org" | ||
|
||
gem "activerecord", "~> 4.2" | ||
|
||
gemspec :path => "../" |
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 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "https://rubygems.org" | ||
|
||
gem "activerecord", "5.0.0.beta1" | ||
gem "activemodel", "5.0.0.beta1" | ||
gem "actionpack", "5.0.0.beta1" | ||
gem "railties", "5.0.0.beta1" | ||
gem "rspec-rails", :github => "rspec/rspec-rails" | ||
gem "rspec-core", :github => "rspec/rspec-core" | ||
gem "rspec-expectations", :github => "rspec/rspec-expectations" | ||
gem "rspec-mocks", :github => "rspec/rspec-mocks" | ||
gem "rspec-support", :github => "rspec/rspec-support" | ||
|
||
gemspec :path => "../" |
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
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,45 +1,55 @@ | ||
require 'test_helper' | ||
require 'sinatra/base' | ||
# Our ActiveRecord 5 gemfile (see `Appraisals`) must use `rack 2.0.0.alpha` | ||
# which renames several files that sinatra 1 depended on. Until there is | ||
# a released version of sinatra that supports `rack 2.0.0.alpha`, we | ||
# must exclude sinatra from our test suite. This is done in two files: | ||
# | ||
# - test/functional/sinatra_test.rb | ||
# - test/functional/modular_sinatra_test.rb | ||
# | ||
if Gem::Version.new(Rack.release) < Gem::Version.new("2.0.0.alpha") | ||
require 'test_helper' | ||
require 'sinatra/base' | ||
|
||
# --- Tests for modular `Sinatra::Base` style ---- | ||
class BaseApp < Sinatra::Base | ||
configs = YAML.load_file(File.expand_path('../../dummy/config/database.yml', __FILE__)) | ||
ActiveRecord::Base.configurations = configs | ||
ActiveRecord::Base.establish_connection(:test) | ||
register PaperTrail::Sinatra | ||
|
||
get '/test' do | ||
Widget.create!(:name => 'foo') | ||
'Hello' | ||
end | ||
class BaseApp < Sinatra::Base | ||
configs = YAML.load_file(File.expand_path('../../dummy/config/database.yml', __FILE__)) | ||
ActiveRecord::Base.configurations = configs | ||
ActiveRecord::Base.establish_connection(:test) | ||
register PaperTrail::Sinatra | ||
|
||
get '/test' do | ||
Widget.create!(:name => 'foo') | ||
'Hello' | ||
end | ||
|
||
def current_user | ||
@current_user ||= OpenStruct.new(id: 'foobar') | ||
def current_user | ||
@current_user ||= OpenStruct.new(id: 'foobar') | ||
end | ||
end | ||
end | ||
|
||
class ModularSinatraTest < ActionDispatch::IntegrationTest | ||
include Rack::Test::Methods | ||
class ModularSinatraTest < ActionDispatch::IntegrationTest | ||
include Rack::Test::Methods | ||
|
||
def app | ||
@app ||= BaseApp | ||
end | ||
def app | ||
@app ||= BaseApp | ||
end | ||
|
||
test 'baseline' do | ||
assert_nil Widget.create.versions.first.whodunnit | ||
end | ||
test 'baseline' do | ||
assert_nil Widget.create.versions.first.whodunnit | ||
end | ||
|
||
context "`PaperTrail::Sinatra` in a `Sinatra::Base` application" do | ||
context "`PaperTrail::Sinatra` in a `Sinatra::Base` application" do | ||
|
||
should "sets the `user_for_paper_trail` from the `current_user` method" do | ||
get '/test' | ||
assert_equal 'Hello', last_response.body | ||
widget = Widget.last | ||
assert_not_nil widget | ||
assert_equal 'foo', widget.name | ||
assert_equal 1, widget.versions.size | ||
assert_equal 'foobar', widget.versions.first.whodunnit | ||
end | ||
should "sets the `user_for_paper_trail` from the `current_user` method" do | ||
get '/test' | ||
assert_equal 'Hello', last_response.body | ||
widget = Widget.last | ||
assert_not_nil widget | ||
assert_equal 'foo', widget.name | ||
assert_equal 1, widget.versions.size | ||
assert_equal 'foobar', widget.versions.first.whodunnit | ||
end | ||
|
||
end | ||
end | ||
end |
Oops, something went wrong.