refactor test to use let instead of instance variables
This commit is contained in:
parent
5fba53a105
commit
880886bbad
1 changed files with 13 additions and 16 deletions
|
|
@ -4,25 +4,22 @@
|
|||
|
||||
require 'spec_helper'
|
||||
|
||||
describe ConversationVisibility, :type => :model do
|
||||
before do
|
||||
@user1 = alice
|
||||
@participant_ids = [@user1.contacts.first.person.id, @user1.person.id]
|
||||
|
||||
@create_hash = {
|
||||
:author => @user1.person,
|
||||
:participant_ids => @participant_ids,
|
||||
:subject => "cool stuff",
|
||||
:messages_attributes => [ {:author => @user1.person, :text => 'hey'} ]
|
||||
describe ConversationVisibility, type: :model do
|
||||
let(:user1) { alice }
|
||||
let(:participant_ids) { [user1.contacts.first.person.id, user1.person.id] }
|
||||
let(:create_hash) do
|
||||
{
|
||||
author: user1.person,
|
||||
participant_ids: participant_ids,
|
||||
subject: 'cool stuff',
|
||||
messages_attributes: [{ author: user1.person, text: 'hey' }]
|
||||
}
|
||||
@conversation = Conversation.create(@create_hash)
|
||||
end
|
||||
let(:conversation) { Conversation.create(create_hash) }
|
||||
|
||||
it 'destroy conversation when no participant' do
|
||||
@conversation.conversation_visibilities.each do |visibility|
|
||||
visibility.destroy
|
||||
end
|
||||
|
||||
expect(Conversation).not_to exist(@conversation.id)
|
||||
conversation.conversation_visibilities.each(&:destroy)
|
||||
|
||||
expect(Conversation).not_to exist(conversation.id)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue