-
Notifications
You must be signed in to change notification settings - Fork 0
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
2 changed files
with
47 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
require 'active_support/concern' | ||
require 'net/http' | ||
# require 'robin' | ||
|
||
module Robin | ||
module Rails | ||
|
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,46 @@ | ||
require 'spec_helper' | ||
require 'robin-rails' | ||
require 'active_record' | ||
|
||
class DummyModel < ActiveRecord::Base | ||
include Robin::Rails | ||
end | ||
|
||
describe Robin::Rails do | ||
before(:all) do | ||
# Throw together a fake DB | ||
ActiveRecord::Base.establish_connection( | ||
:adapter => 'sqlite3', | ||
:database => ':memory:' | ||
) | ||
|
||
ActiveRecord::Migration.verbose = false | ||
ActiveRecord::Schema.define do | ||
create_table :dummy_models, force: true | ||
end | ||
end | ||
|
||
context 'included module' do | ||
before do | ||
Robin.stub(:publish) | ||
end | ||
|
||
it 'calls publish after create' do | ||
Robin.should_receive(:publish).with(anything, :created, anything) | ||
|
||
DummyModel.create | ||
end | ||
|
||
it 'calls publish after update' do | ||
record = DummyModel.create | ||
Robin.should_receive(:publish).with(anything, :updated, anything) | ||
record.save | ||
end | ||
|
||
it 'calls publish after destroy' do | ||
record = DummyModel.create | ||
Robin.should_receive(:publish).with(anything, :destroyed, anything) | ||
record.destroy | ||
end | ||
end | ||
end |