Sha256: c56420e37692541fb8aa5b8e2dcc045bbcdae070d64b57c262344c9c574da443

Contents?: true

Size: 1.68 KB

Versions: 2

Compression:

Stored size: 1.68 KB

Contents

require 'test_helper'

class FeedbackSubmissionTest < ActionDispatch::IntegrationTest
  fixtures :all

  describe "submitting feedback" do
    before do
      visit "/pointless_feedback"

      fill_in_fields

      click_on "Submit"
    end

    test "redirects to the root path" do
      assert_equal current_path, "/"
    end

    test "thanks message is displayed" do
      within('body') do
        assert_match 'Thanks for your feedback!', text
      end
    end
  end

  describe "submitting feedback with the honeypot field filled in" do
    before do
      visit "/pointless_feedback"

      fill_in_fields
      fill_in "message_contact_info", :with => "I'm a spam bot!"

      click_on "Submit"
    end

    test "redirects to the root path" do
      assert_equal current_path, "/"
    end

    test "thanks message is displayed" do
      within('body') do
        assert_match 'Thanks for your feedback!', text
      end
    end
  end

  describe "submitting feedback with the invalid word in description" do
    before do
      PointlessFeedback.invalid_words = ['nymphomania']
      
      visit "/pointless_feedback"

      fill_in_fields
      fill_in "Description", :with => "I got nymphomania."

      click_on "Submit"
    end

    test "redirects to the root path" do
      assert_equal current_path, "/"
    end

    test "thanks message is displayed" do
      within('body') do
        assert_match 'Thanks for your feedback!', text
      end
    end
  end

  def fill_in_fields
    fill_in "Name",          :with => "Eli"
    fill_in "Email address", :with => "eli@example.com"
    select "Other",          :from => "Topic"
    fill_in "Description",   :with => "This site is awful"
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pointless_feedback-4.1.5 test/integration/pointless_feedback/feedback_submission_test.rb
pointless_feedback-4.1.4 test/integration/pointless_feedback/feedback_submission_test.rb