Skip to content

Commit

Permalink
remove deprecated #commit method
Browse files Browse the repository at this point in the history
  • Loading branch information
krisleech committed May 19, 2017
1 parent b55bbb6 commit ebacaae
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 55 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Authors: Kris Leech, robwilliams

* Remove deprecated #commit method (breaking change)
* Update to Wisper 2.0 (non-breaking, but we will released a major anyway)
* fixed README example
* document fixes
Expand Down
13 changes: 0 additions & 13 deletions lib/wisper/active_record/publisher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@ module Publisher
after_rollback :after_rollback_broadcast
end

def commit(_attributes = nil)
warn "[DEPRECATED] use save, create, update_attributes as usual"
assign_attributes(_attributes) if _attributes.present?
save
end

module ClassMethods
def commit(_attributes = nil)
warn "[DEPRECATED] use save, create, update_attributes as usual"
new(_attributes).save
end
end

private

def after_validation_broadcast
Expand Down
42 changes: 0 additions & 42 deletions spec/wisper/activerecord_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,6 @@
expect(Wisper.model).to eq Wisper::ActiveRecord::Publisher
end

describe '.commit' do # DEPRECATED
describe 'when creating' do
context 'and model is valid' do
it 'publishes create_<model_name>_successful event to listener' do
expect(listener).to receive(:create_meeting_successful).with(instance_of(model_class))
model_class.subscribe(listener)
model_class.commit
end
end

context 'and model is not valid' do
it 'publishes create_<model_name>_failed event to listener' do
expect(listener).to receive(:create_meeting_failed).with(instance_of(model_class))
model_class.subscribe(listener)
model_class.commit(title: nil)
end
end
end

describe 'when updating' do
before { model_class.create! }

let(:model) { model_class.first }

context 'and model is valid' do
it 'publishes update_<model_name>_successful event to listener' do
expect(listener).to receive(:update_meeting_successful).with(instance_of(model_class))
model_class.subscribe(listener)
model.commit(title: 'foo')
end
end

context 'and model is not valid' do
it 'publishes update_<model_name>_failed event to listener' do
expect(listener).to receive(:update_meeting_failed).with(instance_of(model_class))
model_class.subscribe(listener)
model.commit(title: nil)
end
end
end
end

describe 'create' do
it 'publishes an after_create event to listener' do
expect(listener).to receive(:after_create).with(instance_of(model_class))
Expand Down

0 comments on commit ebacaae

Please sign in to comment.