Skip to content

Commit

Permalink
move test classes in multiple_tracker_spec.rb into a module
Browse files Browse the repository at this point in the history
  • Loading branch information
O. Bucao committed Oct 31, 2017
1 parent 52cf994 commit 51f3216
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions spec/integration/multiple_trackers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,30 @@
before :all do
Mongoid::History.tracker_class_name = nil

class First
include Mongoid::Document
include Mongoid::History::Trackable
module MultipleTrackersSpec
class First
include Mongoid::Document
include Mongoid::History::Trackable

field :text, type: String
track_history on: [:text],
track_create: true,
track_update: true,
track_destroy: true,
tracker_class_name: :first_history_tracker
end
field :text, type: String
track_history on: [:text],
track_create: true,
track_update: true,
track_destroy: true,
tracker_class_name: :first_history_tracker
end

class Second
include Mongoid::Document
include Mongoid::History::Trackable
class Second
include Mongoid::Document
include Mongoid::History::Trackable

field :text, type: String
track_history on: [:text],
track_create: true,
track_update: true,
track_destroy: true,
tracker_class_name: :second_history_tracker
field :text, type: String
track_history on: [:text],
track_create: true,
track_update: true,
track_destroy: true,
tracker_class_name: :second_history_tracker
end
end

class FirstHistoryTracker
Expand All @@ -40,13 +42,13 @@ class SecondHistoryTracker
it 'should be possible to have different trackers for each class' do
expect(FirstHistoryTracker.count).to eq(0)
expect(SecondHistoryTracker.count).to eq(0)
expect(First.tracker_class).to be FirstHistoryTracker
expect(Second.tracker_class).to be SecondHistoryTracker
expect(MultipleTrackersSpec::First.tracker_class).to be FirstHistoryTracker
expect(MultipleTrackersSpec::Second.tracker_class).to be SecondHistoryTracker

foo = First.new
foo = MultipleTrackersSpec::First.new
foo.save

bar = Second.new
bar = MultipleTrackersSpec::Second.new
bar.save

expect(FirstHistoryTracker.count).to eq 1
Expand Down

0 comments on commit 51f3216

Please sign in to comment.