jam-cloud/web/spec/features/notification_spec.rb

65 lines
1.7 KiB
Ruby

require 'spec_helper'
describe "Notification Subpanel", :js => true, :type => :feature, :capybara_feature => true do
subject { page }
let(:user) { FactoryGirl.create(:user, last_jam_locidispid: 1) }
describe "user with no notifications" do
before(:each) do
fast_signin(user, "/client")
end
it "lists no notifications" do
open_notifications
expect(page).to have_selector("#{NOTIFICATION_PANEL} li.notification-entry", count: 0)
end
end
describe "user with 1 notification" do
let!(:other) { FactoryGirl.create(:user, last_jam_locidispid: 1) }
let!(:msg1) {FactoryGirl.create(:notification_text_message, source_user: other, target_user: user) }
before(:each) do
fast_signin(user, "/client")
end
it "lists 1 notifications" do
open_notifications
expect(page).to have_selector("#{NOTIFICATION_PANEL} li.notification-entry", count: 1)
end
end
end
describe "Notification Toast", js: true, type: :feature, capybara_feature: true do
let(:user) { FactoryGirl.create(:user) }
let(:user1) { FactoryGirl.create(:user) }
let(:user2) { FactoryGirl.create(:user) }
let(:user3) { FactoryGirl.create(:user) }
before(:each) do
fast_signin(user, "/client")
end
it "popup 3 toasts" do
wait_until_curtain_gone
create_friend_request(user1, user)
create_friend_request(user2, user)
create_friend_request(user3, user)
expect(page).to have_selector(".notification", count: 3)
end
def create_friend_request(source_user, targe_user)
req = FriendRequest.new
req.user_id = source_user.id
req.friend_id = targe_user.id
req.save!
Notification.send_friend_request(req.id, source_user.id, targe_user.id)
end
end