mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-11 09:17:20 -04:00
- Move expectations from `before` hooks to `it` blocks. - Ensure controller actions are called after expectations are set in controller specs. - Replace synchronization expectations in hooks with Capybara `find` calls. - Remove RSpec/ExpectInHook from .rubocop_todo.yml. Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>
63 lines
1.6 KiB
Ruby
63 lines
1.6 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe "forums", :js do
|
|
include_context 'signed in admin'
|
|
let(:forum) { create(:forum) }
|
|
|
|
describe "navigating to forum admin with js" do
|
|
before do
|
|
visit admin_path
|
|
within 'nav#site_admin' do
|
|
click_link "Forums"
|
|
end
|
|
end
|
|
|
|
it { expect(page).to have_current_path forums_path, ignore_query: true }
|
|
it { expect(page).to have_link "New forum" }
|
|
end
|
|
|
|
describe "adding a forum" do
|
|
before do
|
|
visit forums_path
|
|
click_link "New forum"
|
|
fill_in 'Name', with: 'Discussion'
|
|
fill_in 'Description', with: "this is a new forum"
|
|
select member.login_name, from: "Owner"
|
|
click_button 'Save'
|
|
end
|
|
|
|
it 'saves' do
|
|
expect(page).to have_content 'Forum was successfully created'
|
|
expect(page).to have_current_path forum_path(Forum.last), ignore_query: true
|
|
end
|
|
end
|
|
|
|
describe 'editing forum' do
|
|
before do
|
|
visit forum_path forum
|
|
click_link 'Edit'
|
|
fill_in 'Name', with: 'Something else'
|
|
click_button 'Save'
|
|
forum.reload
|
|
end
|
|
|
|
it { expect(page).to have_current_path forum_path(forum), ignore_query: true }
|
|
it { expect(page).to have_content 'Forum was successfully updated' }
|
|
it { expect(page).to have_content 'Something else' }
|
|
end
|
|
|
|
describe 'deleting forum' do
|
|
before do
|
|
visit forum_path forum
|
|
accept_confirm do
|
|
click_link 'Delete'
|
|
end
|
|
end
|
|
|
|
it { expect(page).to have_current_path forums_path, ignore_query: true }
|
|
it { expect(page).to have_content 'Forum was successfully deleted' }
|
|
end
|
|
end
|