diaspora/spec/controllers/jasmine_fixtures/conversations_spec.rb
2016-11-13 20:08:59 +01:00

49 lines
1.6 KiB
Ruby

require 'spec_helper'
describe ConversationsController, :type => :controller do
describe '#index' do
before do
@person = alice.contacts.first.person
hash = {
:author => @person,
:participant_ids => [alice.person.id, @person.id],
:subject => 'not spam',
:messages_attributes => [ {:author => @person, :text => 'cool stuff'} ]
}
@conv1 = Conversation.create(hash)
Message.create(:author => @person, :created_at => Time.now + 100, :text => "message", :conversation_id => @conv1.id)
.increase_unread(alice)
Message.create(:author => @person, :created_at => Time.now + 200, :text => "another message", :conversation_id => @conv1.id)
.increase_unread(alice)
@conv2 = Conversation.create(hash)
Message.create(:author => @person, :created_at => Time.now + 100, :text => "message", :conversation_id => @conv2.id)
.increase_unread(alice)
sign_in alice, scope: :user
end
it "generates a jasmine fixture", :fixture => true do
get :index, :conversation_id => @conv1.id
save_fixture(html_for("body"), "conversations_unread")
get :index, :conversation_id => @conv1.id
save_fixture(html_for("body"), "conversations_read")
get :new, modal: true
save_fixture(response.body, "conversations_modal")
end
end
describe "#new" do
before do
sign_in alice, scope: :user
end
it "generates a jasmine fixture", fixture: true do
session[:mobile_view] = true
get :new, format: :mobile
save_fixture(html_for("body"), "conversations_new_mobile")
end
end
end