link-share/spec/features/admin/send_link_spec.rb

44 lines
1 KiB
Ruby
Raw Permalink Normal View History

2015-07-21 10:33:31 -04:00
require 'spec_helper'
describe 'Admin Send Links' do
context 'when not logged in' do
it 'should not allow access to send links' do
visit '/send'
expect(page.status_code).to be(401)
end
end
context 'when logged in' do
let!(:links) { 10.times.collect { create(:link) } }
2016-10-05 20:56:09 -04:00
before(:each) do
basic_auth 'admin', 'password'
allow(SmsNotifier).to receive(:notify)
end
2015-07-21 10:33:31 -04:00
it 'should allow sending of a link' do
visit '/manage'
first('a', text: 'Send').click
expect(page).to have_content('Link has been marked as sent')
end
it 'should remove sent link from unsent list' do
link = create(:link)
visit '/manage'
find('a', text: link.title)
.find(:xpath, '../..')
.find('a', text: 'Send')
.click
expect(page).to_not have_content(link.title)
end
2016-10-05 20:56:09 -04:00
it 'attempts to send an SMS message' do
visit '/manage'
first('a', text: 'Send').click
expect(SmsNotifier).to have_received(:notify)
end
2015-07-21 10:33:31 -04:00
end
end