Files
growstuff/spec/views/posts/new.html.haml_spec.rb
Daniel O'Connor 8b4f0771c5 Ruby 3.2: Rubocop - Fix Negation matcher (#3780)
* Ruby 3.2/Bundler 2.4

* Fix creation

* Upgrade to js-routes 2. Put all js routes into a global namespace.

* Remove js-routes

* Remove

* Adjust ownership

* Appease codeclimate for the nth time

* Fix deprecation warning by explicitly calling to_fs

* Fix deprecation warning by explicitly calling to_fs

* Fix deprecation warning by explicitly calling to_fs

* Swap to will paginate successor for bootstrap

* Update app/views/members/show.html.haml

* Update app/views/plantings/index.rss.haml

* Update .env

* Update .devcontainer/.env

* Fix spec

* Update spec

* Fix spec

* Pin to 2.4.22

* 3 space indent

* Regenerate

* Update rubocop

* Rubocop

* More rubocop

* Regenerate

* Fix Capybara/NegationMatcher
2024-07-13 15:20:11 +09:30

64 lines
1.7 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
describe "posts/new" do
let(:author) { FactoryBot.create(:member) }
before do
assign(:post, FactoryBot.create(:post, author:))
# assign(:forum, Forum.new)
sign_in author
controller.stub(:current_user) { author }
render
end
it "renders new post form" do
assert_select "form", action: posts_path, method: "post" do
assert_select "input#post_subject", name: "post[subject]"
assert_select "textarea#post_body", name: "post[body]"
end
end
it 'no hidden forum field' do
assert_select "input#post_forum_id[type=hidden]", false
end
it 'no forum mentioned' do
expect(rendered).to have_no_content "This post will be posted in the forum"
end
it "asks what's going on in your garden" do
expect(rendered).to have_content "What's going on in your food garden?"
end
it 'shows markdown help' do
expect(rendered).to have_content 'Markdown'
end
context "forum specified" do
let(:forum) { FactoryBot.create(:forum) }
before do
assign(:forum, forum)
assign(:post, FactoryBot.create(:post, forum:))
render
end
it 'creates a hidden field' do
assert_select "input#post_forum_id[type='hidden'][value='#{forum.id}']"
end
it 'tells the user what forum it will be posted in' do
expect(rendered).to have_content "This post will be posted in the forum #{forum.name}"
end
it { expect(rendered).to have_link forum.name }
describe "asks what's going on generally" do
it { expect(rendered).to have_content "What's going on in your food garden?" }
it { expect(rendered).to have_content "What's up?" }
end
end
end