This repository has been archived by the owner on Oct 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
425 additions
and
77 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 |
---|---|---|
|
@@ -5,5 +5,8 @@ | |
/coverage/ | ||
/doc/ | ||
/pkg/ | ||
/spec/rails/ | ||
/spec/reports/ | ||
/tmp/ | ||
/gemfiles/*.gemfile.lock | ||
/gemfiles/vendor/ |
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,12 @@ | ||
appraise 'rails42' do | ||
gem 'rails', '~> 4.2.0' | ||
gem "paper_trail", "~> 4.2.0" | ||
gem 'activeadmin', '1.0.0.pre4' | ||
end | ||
|
||
appraise 'rails50' do | ||
gem 'rails', '~> 5.0.0' | ||
gem "paper_trail", "~> 5.2.2" | ||
gem 'inherited_resources', github: 'activeadmin/inherited_resources' | ||
gem 'activeadmin', github: 'activeadmin/activeadmin' | ||
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 |
---|---|---|
@@ -1,4 +1,23 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in active_admin_versioning.gemspec | ||
gemspec | ||
|
||
gem "rails", "~> 5.0.0" | ||
gem "paper_trail", "~> 5.2.2" | ||
gem "inherited_resources", github: "activeadmin/inherited_resources" | ||
gem "activeadmin", github: "activeadmin/activeadmin" | ||
gem "pry" | ||
gem 'appraisal' | ||
|
||
group :development do | ||
gem "rubocop", "~> 0.40.0" | ||
end | ||
|
||
group :test do | ||
gem "capybara" | ||
gem "rspec-rails" | ||
gem "database_cleaner" | ||
gem 'shoulda-matchers' | ||
gem "sqlite3", platforms: :mri | ||
gem "poltergeist" | ||
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
require "bundler/gem_tasks" | ||
require "rspec/core/rake_task" | ||
require 'bundler' | ||
require 'rake' | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
Bundler.setup | ||
Bundler::GemHelper.install_tasks | ||
|
||
task :default => :spec | ||
FileList['tasks/**/*.rake'].each { |task| import task } |
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 @@ | ||
--- | ||
BUNDLE_DISABLE_SHARED_GEMS: "true" |
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,25 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "https://rubygems.org" | ||
|
||
gem "rails", "~> 4.2.0" | ||
gem "paper_trail", "~> 4.2.0" | ||
gem "inherited_resources", :github => "activeadmin/inherited_resources" | ||
gem "activeadmin", "1.0.0.pre4" | ||
gem "pry" | ||
gem "appraisal" | ||
|
||
group :development do | ||
gem "rubocop", "~> 0.40.0" | ||
end | ||
|
||
group :test do | ||
gem "capybara" | ||
gem "rspec-rails" | ||
gem "database_cleaner" | ||
gem "shoulda-matchers" | ||
gem "sqlite3", :platforms => :mri | ||
gem "poltergeist" | ||
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,25 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "https://rubygems.org" | ||
|
||
gem "rails", "~> 5.0.0" | ||
gem "paper_trail", "~> 5.2.2" | ||
gem "inherited_resources", :github => "activeadmin/inherited_resources" | ||
gem "activeadmin", :github => "activeadmin/activeadmin" | ||
gem "pry" | ||
gem "appraisal" | ||
|
||
group :development do | ||
gem "rubocop", "~> 0.40.0" | ||
end | ||
|
||
group :test do | ||
gem "capybara" | ||
gem "rspec-rails" | ||
gem "database_cleaner" | ||
gem "shoulda-matchers" | ||
gem "sqlite3", :platforms => :mri | ||
gem "poltergeist" | ||
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 |
---|---|---|
@@ -1,2 +1,11 @@ | ||
require "active_admin" | ||
require "paper_trail/version_concern" | ||
require "active_admin_versioning/engine" | ||
require "active_admin_versioning/version" | ||
require "active_admin_versioning/active_admin/application" | ||
require "active_admin_versioning/active_admin/dsl" | ||
require "active_admin_versioning/active_admin/resource_controller" | ||
require "active_admin_versioning/paper_trail/version_concern" | ||
|
||
::ActiveAdmin::Application.send :prepend, ActiveAdminVersioning::ActiveAdmin::Application | ||
::ActiveAdmin::DSL.send :include, ActiveAdminVersioning::ActiveAdmin::DSL | ||
::PaperTrail::VersionConcern.send :include, ActiveAdminVersioning::PaperTrail::VersionConcern |
2 changes: 1 addition & 1 deletion
2
...admin_versioning/extension/application.rb → ...in_versioning/active_admin/application.rb
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,49 @@ | ||
module ActiveAdminVersioning | ||
module ActiveAdmin | ||
module DSL | ||
def versioning | ||
return unless enabled_paper_trail? | ||
|
||
controller { include ActiveAdminVersioning::ActiveAdmin::ResourceController } | ||
|
||
member_action(:versions) do | ||
@versions = resource.versions.reorder(id: :desc, created_at: :desc).page(params[:page]) | ||
@page_title = ::PaperTrail::Version.model_name.human | ||
render "versions" | ||
end | ||
|
||
with_options only: :show do | ||
action_item :version do | ||
link_to send("versions_admin_#{resource_instance_name}_path") do | ||
::PaperTrail::Version.model_name.human | ||
end | ||
end | ||
|
||
sidebar ::PaperTrail::Version.model_name.human do | ||
if versions.present? | ||
attributes_table_for versions[0] do | ||
row ::PaperTrail::Version.model_name.human do |_| | ||
version_number | ||
end | ||
row :event, &:event_i18n | ||
row :whodunnit do |record| | ||
record.whodunnit.presence || span(t("views.version.unknown_user"), class: "empty") | ||
end | ||
row :created_at | ||
end | ||
paginate versions, theme: :version | ||
else | ||
I18n.t("views.version.empty", model_name: ::PaperTrail::Version.model_name.human) | ||
end | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def enabled_paper_trail? | ||
config.resource_class.try(:paper_trail).try(:enabled?) || config.resource_class.try(:paper_trail_enabled_for_model?) | ||
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
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,16 +1,6 @@ | ||
require "rails" | ||
require "rails/engine" | ||
|
||
module ActiveAdminVersioning | ||
class Engine < ::Rails::Engine | ||
config.after_initialize do | ||
require "active_admin_versioning/extension/application" | ||
require "active_admin_versioning/extension/dsl" | ||
require "active_admin_versioning/extension/resource_controller" | ||
require "active_admin_versioning/extension/paper_trail" | ||
|
||
::ActiveAdmin::Application.send :prepend, ActiveAdminVersioning::Extension::Application | ||
::ActiveAdmin::DSL.send :include, ActiveAdminVersioning::Extension::DSL | ||
::PaperTrail::Version.send :include, ActiveAdminVersioning::Extension::PaperTrail | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...admin_versioning/extension/paper_trail.rb → ...versioning/paper_trail/version_concern.rb
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 ActiveAdminVersioning | ||
VERSION = "0.1.0".freeze | ||
VERSION = "0.1.1".freeze | ||
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,65 @@ | ||
require "spec_helper" | ||
|
||
describe "integration test", type: :feature do | ||
def random_word | ||
"string".scan(/\w/).shuffle.join | ||
end | ||
|
||
def create_post | ||
fill_in "post_title", with: random_word | ||
fill_in "post_body", with: random_word | ||
click_button "Create Post" | ||
end | ||
|
||
def update_post | ||
fill_in "post_title", with: random_word | ||
fill_in "post_body", with: random_word | ||
click_button "Update Post" | ||
end | ||
|
||
describe "visit page of resource is enabled paper_trail" do | ||
before do | ||
visit "/admin/posts/new" | ||
create_post | ||
|
||
click_link "Edit Post" | ||
update_post | ||
end | ||
|
||
describe "viewable registered content" do | ||
let(:post) { Post.first } | ||
let(:current_version) { post.versions.last } | ||
|
||
it "should have elements are registered by dsl" do | ||
within ".action_items" do | ||
page.should have_link "Version", href: versions_admin_post_path(1) | ||
end | ||
|
||
within "#sidebar" do | ||
page.should have_css "#version_sidebar_section" | ||
page.should have_selector "#version_sidebar_section h3", text: "Version" | ||
page.should have_selector "tr.row-version td", text: post.versions.size | ||
page.should have_selector "tr.row-event td", text: current_version.event | ||
page.should have_selector "tr.row-whodunnit td", text: current_version.whodunnit | ||
end | ||
end | ||
end | ||
|
||
describe "viewable versions page" do | ||
let(:post) { Post.first } | ||
|
||
before { click_link "Version" } | ||
|
||
it "should have content" do | ||
post.versions.each do |version| | ||
within "#paper_trail_version_#{version.id}" do | ||
page.should have_selector "td.col-id", text: version.id | ||
page.should have_selector "td.col-whodunnit", text: version.whodunnit | ||
page.should have_selector "td.col-event", text: version.event | ||
page.should have_selector "td.col-item_type", text: version.item_type | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.