creddit/spec/features/subcreddits/close_subcreddit_spec.rb

64 lines
1.5 KiB
Ruby
Raw Normal View History

require 'rails_helper'
describe 'Edit Subcreddit', type: :feature do
before(:each) { signout }
context 'when logged in' do
2015-12-14 13:28:39 -05:00
let!(:user) { create(:user) }
before(:each) { signin(user: user) }
2015-12-14 13:28:39 -05:00
context 'when user is owner' do
let!(:subcreddit) { create(:subcreddit, owner: user) }
context 'when board is open' do
before(:each) do
visit subcreddits_path
click_link 'Edit'
check :subcreddit_closed
click_button 'Update Subcreddit'
end
it 'should be notified the subcreddit was updated' do
expect(page).to have_content('updated')
end
it 'should close the board when closed is checked' do
expect(page).to have_content('closed')
end
end
2015-12-14 13:28:39 -05:00
context 'when board is closed' do
let!(:subcreddit) do
create(:subcreddit, owner: user, closed_at: Time.now)
end
before(:each) do
visit subcreddits_path
click_link 'Edit'
uncheck :subcreddit_closed
click_button 'Update Subcreddit'
end
it 'should open the board when closed is checked' do
expect(page).to_not have_content('closed')
end
end
end
2015-12-14 13:28:39 -05:00
context 'when not owner' do
let!(:subcreddit) { create(:subcreddit) }
it 'should not allow editing of subcreddit' do
visit subcreddits_path
click_link 'Edit'
2015-12-14 13:28:39 -05:00
expect(page).to have_content('not authorized')
end
end
end
2015-12-14 13:28:39 -05:00
context 'when not logged in' do
end
end