2015-07-14 16:29:22 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe 'Edit Post', type: :feature do
|
|
|
|
context 'when signed in' do
|
|
|
|
let!(:user) { create(:user) }
|
|
|
|
let!(:subcreddit) { create(:subcreddit) }
|
|
|
|
let!(:post) { create(:post, subcreddit: subcreddit, user: user) }
|
|
|
|
let(:new_post) { build_stubbed(:post) }
|
|
|
|
|
|
|
|
before(:each) { signin(user: user) }
|
|
|
|
|
|
|
|
context 'with valid data' do
|
|
|
|
before(:each) do
|
|
|
|
visit edit_subcreddit_post_path(subcreddit, post)
|
|
|
|
|
|
|
|
fill_in :post_title, with: new_post.title
|
|
|
|
fill_in :post_link, with: new_post.link
|
|
|
|
fill_in :post_content, with: new_post.content
|
|
|
|
|
|
|
|
click_button 'Update Post'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should notify that the post was edited' do
|
|
|
|
expect(page).to have_content('updated')
|
|
|
|
end
|
|
|
|
|
2015-07-16 11:57:27 -04:00
|
|
|
it 'should show the updated post' do
|
2015-07-14 16:29:22 -04:00
|
|
|
expect(page).to have_content(new_post.title)
|
2015-07-16 11:57:27 -04:00
|
|
|
expect(page).to have_content(new_post.content)
|
2015-07-14 16:29:22 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|