Rubocop spec/models/supporter_note_spec.rb
This commit is contained in:
parent
83e7c33e45
commit
916fd18da5
2 changed files with 111 additions and 99 deletions
|
@ -594,7 +594,6 @@ AllCops:
|
||||||
- 'spec/models/campaign_gift_purchase_spec.rb'
|
- 'spec/models/campaign_gift_purchase_spec.rb'
|
||||||
- 'spec/models/custom_field_master_spec.rb'
|
- 'spec/models/custom_field_master_spec.rb'
|
||||||
- 'spec/models/user_spec.rb'
|
- 'spec/models/user_spec.rb'
|
||||||
- 'spec/models/supporter_note_spec.rb'
|
|
||||||
- 'spec/models/modern_campaign_gift_spec.rb'
|
- 'spec/models/modern_campaign_gift_spec.rb'
|
||||||
- 'spec/models/import_request_spec.rb'
|
- 'spec/models/import_request_spec.rb'
|
||||||
- 'spec/models/nonprofit_spec.rb'
|
- 'spec/models/nonprofit_spec.rb'
|
||||||
|
|
|
@ -3,110 +3,123 @@
|
||||||
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
|
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
|
||||||
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
|
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
# rubocop:disable RSpec/MessageSpies
|
||||||
|
# rubocop:disable RSpec/ExampleLength
|
||||||
|
# rubocop:disable RSpec/MultipleExpectations
|
||||||
RSpec.describe SupporterNote, type: :model do
|
RSpec.describe SupporterNote, type: :model do
|
||||||
include_context :shared_donation_charge_context
|
include_context :shared_donation_charge_context
|
||||||
let(:content) { "CONTENT"}
|
let(:content) { 'CONTENT' }
|
||||||
let(:content2) {"CONTENT2"}
|
let(:content2) { 'CONTENT2' }
|
||||||
|
|
||||||
let(:supporter_note) { supporter.supporter_notes.create(content: content, user: user) }
|
let(:supporter_note) { supporter.supporter_notes.create(content: content, user: user) }
|
||||||
|
|
||||||
it 'creates' do
|
it 'creates' do
|
||||||
expect(supporter_note.errors).to be_empty
|
expect(supporter_note.errors).to be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'announces created' do
|
it 'announces created' do
|
||||||
expect(Houdini.event_publisher).to receive(:announce).with(:supporter_created, anything)
|
expect(Houdini.event_publisher).to receive(:announce).with(:supporter_created, anything)
|
||||||
expect(Houdini.event_publisher).to receive(:announce).with(:supporter_address_created, anything)
|
expect(Houdini.event_publisher).to receive(:announce).with(:supporter_address_created, anything)
|
||||||
expect(Houdini.event_publisher).to receive(:announce).with(:supporter_note_created, {
|
expect(Houdini.event_publisher).to receive(:announce).with(
|
||||||
'id' => match_houid('objevt'),
|
:supporter_note_created,
|
||||||
'object' => 'object_event',
|
{
|
||||||
'type' => 'supporter_note.created',
|
'id' => match_houid('objevt'),
|
||||||
'data' => {
|
'object' => 'object_event',
|
||||||
'object' => {
|
'type' => 'supporter_note.created',
|
||||||
'id'=> kind_of(Numeric),
|
'data' => {
|
||||||
'deleted' => false,
|
'object' => {
|
||||||
'content' => content,
|
'id' => kind_of(Numeric),
|
||||||
'nonprofit'=> {
|
'deleted' => false,
|
||||||
'id' => nonprofit.id,
|
'content' => content,
|
||||||
'name' => nonprofit.name,
|
'nonprofit' => {
|
||||||
'object' => 'nonprofit'
|
'id' => nonprofit.id,
|
||||||
},
|
'name' => nonprofit.name,
|
||||||
'object' => 'supporter_note',
|
'object' => 'nonprofit'
|
||||||
'user' => {
|
},
|
||||||
'id' => user.id,
|
'object' => 'supporter_note',
|
||||||
'object' => 'user'
|
'user' => {
|
||||||
},
|
'id' => user.id,
|
||||||
'supporter' => supporter_to_builder_base.merge({'name' => "Fake Supporter Name"})
|
'object' => 'user'
|
||||||
}
|
},
|
||||||
}
|
'supporter' => supporter_to_builder_base.merge({ 'name' => 'Fake Supporter Name' })
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
supporter_note
|
supporter_note
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'announces updated' do
|
it 'announces updated' do
|
||||||
expect(Houdini.event_publisher).to receive(:announce).with(:supporter_created, anything)
|
expect(Houdini.event_publisher).to receive(:announce).with(:supporter_created, anything)
|
||||||
expect(Houdini.event_publisher).to receive(:announce).with(:supporter_address_created, anything)
|
expect(Houdini.event_publisher).to receive(:announce).with(:supporter_address_created, anything)
|
||||||
expect(Houdini.event_publisher).to receive(:announce).with(:supporter_note_created, anything).ordered
|
expect(Houdini.event_publisher).to receive(:announce).with(:supporter_note_created, anything).ordered
|
||||||
expect(Houdini.event_publisher).to receive(:announce).with(:supporter_note_updated, {
|
expect(Houdini.event_publisher).to receive(:announce).with(
|
||||||
'id' => match_houid('objevt'),
|
:supporter_note_updated,
|
||||||
'object' => 'object_event',
|
{
|
||||||
'type' => 'supporter_note.updated',
|
'id' => match_houid('objevt'),
|
||||||
'data' => {
|
'object' => 'object_event',
|
||||||
'object' => {
|
'type' => 'supporter_note.updated',
|
||||||
'id'=> kind_of(Numeric),
|
'data' => {
|
||||||
'deleted' => false,
|
'object' => {
|
||||||
'content' => content2,
|
'id' => kind_of(Numeric),
|
||||||
'nonprofit'=> {
|
'deleted' => false,
|
||||||
'id' => nonprofit.id,
|
'content' => content2,
|
||||||
'name' => nonprofit.name,
|
'nonprofit' => {
|
||||||
'object' => 'nonprofit'
|
'id' => nonprofit.id,
|
||||||
},
|
'name' => nonprofit.name,
|
||||||
'object' => 'supporter_note',
|
'object' => 'nonprofit'
|
||||||
'user' => {
|
},
|
||||||
'id' => user.id,
|
'object' => 'supporter_note',
|
||||||
'object' => 'user'
|
'user' => {
|
||||||
},
|
'id' => user.id,
|
||||||
'supporter' => supporter_to_builder_base.merge({'name' => "Fake Supporter Name"})
|
'object' => 'user'
|
||||||
}
|
},
|
||||||
}
|
'supporter' => supporter_to_builder_base.merge({ 'name' => 'Fake Supporter Name' })
|
||||||
}).ordered
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
).ordered
|
||||||
|
|
||||||
supporter_note
|
supporter_note
|
||||||
supporter_note.content = content2
|
supporter_note.content = content2
|
||||||
supporter_note.save!
|
supporter_note.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'announces deleted' do
|
|
||||||
expect(Houdini.event_publisher).to receive(:announce).with(:supporter_created, anything)
|
|
||||||
expect(Houdini.event_publisher).to receive(:announce).with(:supporter_address_created, anything)
|
|
||||||
expect(Houdini.event_publisher).to receive(:announce).with(:supporter_note_created, anything).ordered
|
|
||||||
expect(Houdini.event_publisher).to receive(:announce).with(:supporter_note_deleted, {
|
|
||||||
'id' => match_houid('objevt'),
|
|
||||||
'object' => 'object_event',
|
|
||||||
'type' => 'supporter_note.deleted',
|
|
||||||
'data' => {
|
|
||||||
'object' => {
|
|
||||||
'id'=> kind_of(Numeric),
|
|
||||||
'deleted' => true,
|
|
||||||
'content' => content,
|
|
||||||
'nonprofit'=> {
|
|
||||||
'id' => nonprofit.id,
|
|
||||||
'name' => nonprofit.name,
|
|
||||||
'object' => 'nonprofit'
|
|
||||||
},
|
|
||||||
'object' => 'supporter_note',
|
|
||||||
'user' => {
|
|
||||||
'id' => user.id,
|
|
||||||
'object' => 'user'
|
|
||||||
},
|
|
||||||
'supporter' => supporter_to_builder_base.merge({'name' => "Fake Supporter Name"})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).ordered
|
|
||||||
|
|
||||||
supporter_note.discard!
|
|
||||||
|
|
||||||
end
|
it 'announces deleted' do
|
||||||
|
allow(Houdini.event_publisher)
|
||||||
|
expect(Houdini.event_publisher).to receive(:announce).with(:supporter_created, anything)
|
||||||
|
expect(Houdini.event_publisher).to receive(:announce).with(:supporter_address_created, anything)
|
||||||
|
expect(Houdini.event_publisher).to receive(:announce).with(:supporter_note_created, anything).ordered
|
||||||
|
expect(Houdini.event_publisher).to receive(:announce).with(
|
||||||
|
:supporter_note_deleted,
|
||||||
|
{
|
||||||
|
'id' => match_houid('objevt'),
|
||||||
|
'object' => 'object_event',
|
||||||
|
'type' => 'supporter_note.deleted',
|
||||||
|
'data' => {
|
||||||
|
'object' => {
|
||||||
|
'id' => kind_of(Numeric),
|
||||||
|
'deleted' => true,
|
||||||
|
'content' => content,
|
||||||
|
'nonprofit' => {
|
||||||
|
'id' => nonprofit.id,
|
||||||
|
'name' => nonprofit.name,
|
||||||
|
'object' => 'nonprofit'
|
||||||
|
},
|
||||||
|
'object' => 'supporter_note',
|
||||||
|
'user' => {
|
||||||
|
'id' => user.id,
|
||||||
|
'object' => 'user'
|
||||||
|
},
|
||||||
|
'supporter' => supporter_to_builder_base.merge({ 'name' => 'Fake Supporter Name' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
).ordered
|
||||||
|
|
||||||
|
supporter_note.discard!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# rubocop:enable all
|
||||||
|
|
Loading…
Reference in a new issue