2015-07-14 01:22:50 -04:00
|
|
|
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-07-14 01:22:50 -04:00
|
|
|
|
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
|
2015-07-14 01:22:50 -04:00
|
|
|
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
|
2015-07-14 01:22:50 -04:00
|
|
|
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
|
2015-07-14 01:22:50 -04:00
|
|
|
visit subcreddits_path
|
|
|
|
click_link 'Edit'
|
|
|
|
|
2015-12-14 13:28:39 -05:00
|
|
|
expect(page).to have_content('not authorized')
|
2015-07-14 01:22:50 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-12-14 13:28:39 -05:00
|
|
|
|
|
|
|
context 'when not logged in' do
|
|
|
|
|
|
|
|
end
|
2015-07-14 01:22:50 -04:00
|
|
|
end
|