Browse Source

add creator_id and updator_id to versions

pull/1/head
Nicolae Claudius 11 years ago
parent
commit
adaea5254d
  1. 1
      config/initializers/paper_trail.rb
  2. 6
      db/migrate/20140526093613_add_userstamps_to_versions.rb
  3. 4
      db/schema.rb
  4. 6
      spec/models/domain_spec.rb

1
config/initializers/paper_trail.rb

@ -0,0 +1 @@
PaperTrail::Version.send :include, Stampable

6
db/migrate/20140526093613_add_userstamps_to_versions.rb

@ -0,0 +1,6 @@
class AddUserstampsToVersions < ActiveRecord::Migration
def change
add_column :versions, :creator_id, :integer
add_column :versions, :updator_id, :integer
end
end

4
db/schema.rb

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140117135341) do
ActiveRecord::Schema.define(version: 20140526093613) do
create_table "admins", force: true do |t|
t.string "email", default: "", null: false
@ -177,6 +177,8 @@ ActiveRecord::Schema.define(version: 20140117135341) do
t.string "whodunnit"
t.text "object"
t.datetime "created_at"
t.integer "creator_id"
t.integer "updator_id"
end
add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id", using: :btree

6
spec/models/domain_spec.rb

@ -162,9 +162,13 @@ describe Domain do
subsubdomain.reload.depth.should == 2
end
it "audits creations" do
it "audits creations", focus: true do
PaperTrail.enabled = true
User.current = user
expect { domain }.to change(PaperTrail::Version, :count)
domain.versions.last.creator_id.should == user.id
domain.versions.last.updator_id.should == user.id
User.current = nil
PaperTrail.enabled = false
end

Loading…
Cancel
Save