Skip to content

Commit

Permalink
Merge pull request #15 from botandrose/rails4
Browse files Browse the repository at this point in the history
Support Rails 3.2, 4.0, 4.1, and 4.2.
  • Loading branch information
reidab committed Mar 15, 2015
2 parents 068469b + a474e06 commit 1eb5186
Show file tree
Hide file tree
Showing 18 changed files with 75 additions and 42 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ rvm:
- 2.1
gemfile:
- gemfiles/rails_3.2.gemfile
- gemfiles/rails_4.0.gemfile
- gemfiles/rails_4.1.gemfile
- gemfiles/rails_4.2.gemfile
cache: bundler
12 changes: 12 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
appraise "rails-3.2" do
gem "rails", "3.2.21"
end

appraise "rails-4.0" do
gem "rails", "4.0.9"
end

appraise "rails-4.1" do
gem "rails", "4.1.9"
end

appraise "rails-4.2" do
gem "rails", "4.2.0"
end
2 changes: 1 addition & 1 deletion app/views/paper_trail_manager/changes/_version.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<% end %>
<% end %>
<% if change_revert_allowed?(version) %>
<%= link_to 'Roll back', change_path(version), :method => 'put', :confirm => 'Are you sure?', :class => 'rollback' %>
<%= link_to 'Roll back', change_path(version), :method => 'put', :class => 'rollback', :data => { :confirm => 'Are you sure?' } %>
<% end %>
</p>
<% if version.event == 'update' or version.event == 'create' %>
Expand Down
7 changes: 7 additions & 0 deletions gemfiles/rails_4.0.gemfile
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 "rails", "4.0.9"

gemspec :path => "../"
7 changes: 7 additions & 0 deletions gemfiles/rails_4.1.gemfile
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 "rails", "4.1.9"

gemspec :path => "../"
7 changes: 7 additions & 0 deletions gemfiles/rails_4.2.gemfile
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 "rails", "4.2.0"

gemspec :path => "../"
2 changes: 1 addition & 1 deletion paper_trail_manager.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.add_dependency "rails", "~> 3.0"
spec.add_dependency "rails", [">= 3.0", "< 5.0"]
spec.add_dependency "paper_trail", "~> 3.0"
spec.add_dependency "will_paginate", "~> 3.0"

Expand Down
2 changes: 0 additions & 2 deletions spec/dummy/app/models/entity.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
class Entity < ActiveRecord::Base
has_paper_trail

attr_accessible :name, :status

validates_presence_of :name
validates_presence_of :status
end
2 changes: 0 additions & 2 deletions spec/dummy/app/models/platform.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
class Platform < ActiveRecord::Base
has_paper_trail

attr_accessible :name, :status

validates_presence_of :name
validates_presence_of :status
end
2 changes: 1 addition & 1 deletion spec/dummy/app/views/entities/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<tr>
<td><%= link_to 'Show', entity %></td>
<td><%= link_to 'Edit', edit_entity_path(entity) %></td>
<td><%= link_to 'Destroy', entity, :confirm => 'Are you sure?', :method => :delete %></td>
<td><%= link_to 'Destroy', entity, :method => :delete, :data => { :confirm => 'Are you sure?' } %></td>
</tr>
<% end %>
</table>
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/app/views/platforms/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<tr>
<td><%= link_to 'Show', platform %></td>
<td><%= link_to 'Edit', edit_platform_path(platform) %></td>
<td><%= link_to 'Destroy', platform, :confirm => 'Are you sure?', :method => :delete %></td>
<td><%= link_to 'Destroy', platform, :method => :delete, :data => { :confirm => 'Are you sure?' } %></td>
</tr>
<% end %>
</table>
Expand Down
4 changes: 3 additions & 1 deletion spec/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ class Application < Rails::Application
# This will create an empty whitelist of attributes available for mass-assignment for all models
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
# parameters by using an attr_accessible or attr_protected declaration.
config.active_record.whitelist_attributes = true
if Rails.version < "4.1"
config.active_record.whitelist_attributes = false
end

# Enable the asset pipeline
config.assets.enabled = true
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
config.action_dispatch.best_standards_support = :builtin

# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict
# config.active_record.mass_assignment_sanitizer = :strict

# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
config.action_controller.perform_caching = true

# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false
# config.serve_static_assets = false

# Compress JavaScripts and CSS
config.assets.compress = true
Expand Down
9 changes: 4 additions & 5 deletions spec/dummy/config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@
config.cache_classes = true

# Configure static asset server for tests with Cache-Control for performance
config.serve_static_assets = true
# config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"

# Log error messages when you accidentally call methods on nil
config.whiny_nils = true

# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
Expand All @@ -30,7 +27,9 @@
config.action_mailer.delivery_method = :test

# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict
# config.active_record.mass_assignment_sanitizer = :strict

config.eager_load = false

# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/config/initializers/secret_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
Rails328::Application.config.secret_token = '96169e00f121ca10adb3df3e38edd800c2b0972dc6c9054a9e124979643558199e4245eb3bd60d0fb0f6e71734cc170ce4b57721e55fa106221cda73c9281c5e'
Rails328::Application.config.secret_key_base = Rails328::Application.config.secret_token = '96169e00f121ca10adb3df3e38edd800c2b0972dc6c9054a9e124979643558199e4245eb3bd60d0fb0f6e71734cc170ce4b57721e55fa106221cda73c9281c5e'
36 changes: 18 additions & 18 deletions spec/dummy/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,33 @@
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(:version => 20110228094444) do
ActiveRecord::Schema.define(version: 20110228094444) do

create_table "entities", :force => true do |t|
t.string "name"
t.string "status"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
create_table "entities", force: :cascade do |t|
t.string "name", limit: 255
t.string "status", limit: 255
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "platforms", :force => true do |t|
t.string "name"
t.string "status"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
create_table "platforms", force: :cascade do |t|
t.string "name", limit: 255
t.string "status", limit: 255
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "versions", :force => true do |t|
t.string "item_type", :null => false
t.integer "item_id", :null => false
t.string "event", :null => false
t.string "whodunnit"
create_table "versions", force: :cascade do |t|
t.string "item_type", limit: 255, null: false
t.integer "item_id", null: false
t.string "event", limit: 255, null: false
t.string "whodunnit", limit: 255
t.text "object"
t.datetime "created_at"
end

add_index "versions", ["item_type", "item_id"], :name => "index_versions_on_item_type_and_item_id"
add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id"

end
14 changes: 7 additions & 7 deletions spec/integration/paper_trail_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ def populate
end

context "with changes" do
before(:all) do
before do
populate
end

after(:all) do
after do
Entity.destroy_all
Platform.destroy_all
PaperTrail::Version.destroy_all
Expand All @@ -55,7 +55,7 @@ def populate
context "when getting all changes" do
context "and authorized" do
context "and getting default index" do
before(:all) { get changes_path }
before { get changes_path }

it "should have all changes" do
versions.size.should == 10
Expand Down Expand Up @@ -90,7 +90,7 @@ def populate
end

context "and getting invalid pagination" do
before(:all) { get changes_path(:page => "Shanghai", :per_page => "Alice") }
before { get changes_path(:page => "Shanghai", :per_page => "Alice") }

it "should set default :page parameter" do
assigns[:page].should be_nil
Expand All @@ -110,7 +110,7 @@ def populate

context "when getting changes for a specific type" do
context "that exists" do
before(:all) { get changes_path(:type => "Entity") }
before { get changes_path(:type => "Entity") }

it "should show a subset of the changes" do
versions.size.should == 6
Expand All @@ -129,7 +129,7 @@ def populate

context "when getting changes for a specific record" do
context "that exists" do
before(:all) { get changes_path(:type => "Entity", :id => @reimu.id) }
before { get changes_path(:type => "Entity", :id => @reimu.id) }

it "should show a subset of the changes" do
versions.size.should == 3
Expand All @@ -154,7 +154,7 @@ def populate
context "show a change" do
context "that exists" do
context "when authorized" do
before(:all) do
before do
@version = @reimu.versions.last
get change_path(@version)
end
Expand Down

0 comments on commit 1eb5186

Please sign in to comment.