Sha256: bd0a740271896137f5407ebdb2f54679338d3c5eea3fdc80ccd04e69dc175f1c

Contents?: true

Size: 1.61 KB

Versions: 83

Compression:

Stored size: 1.61 KB

Contents

require 'spec_helper'
include RequestHelpers

describe 'An admin viewing the contacts index', js: true do
  let!(:admin) { FactoryGirl.create(:admin) }

  context 'when there is a contact' do
    let!(:contact) { create(:contact) }
    before do
      login(admin)
    end

    it 'should see the contact in a list' do
      visit contacts_path
      expect(page).to have_content('This is the message!')
    end

    it 'should be able to delete the contact' do
      visit contacts_path
      click_on 'Delete'
      expect(page).not_to have_content('This is the message!')
    end

    %w(read replied).each do |action|
      context "if #{action} is false" do
        it "should be able to toggle #{action} to true" do
          visit contacts_path
          within('ul#contacts') do
            expect(page).to have_selector("a.toggle.#{action}.false")
            page.find("a.toggle.#{action}").click
            expect(contact.reload.send("toggle_#{action}!")).to be_true
            expect(page).to have_selector("a.toggle.#{action}.true")
          end
        end

        context "if #{action} is true" do
          it "should be able to toggle #{action} to false" do
            contact.update_attributes(action.to_sym => true)
            visit contacts_path
            within('ul#contacts') do
              expect(page).to have_selector("a.toggle.#{action}.true")
              page.find("a.toggle.#{action}").click
              expect(contact.reload.send("toggle_#{action}!")).to be_true
              expect(page).to have_selector("a.toggle.#{action}.false")
            end
          end
        end
      end
    end
  end
end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
tenon-1.1.8 spec/features/tenon/contacts_spec.rb
tenon-1.1.7 spec/features/tenon/contacts_spec.rb
tenon-1.1.6 spec/features/tenon/contacts_spec.rb
tenon-1.1.5 spec/features/tenon/contacts_spec.rb
tenon-1.1.4 spec/features/tenon/contacts_spec.rb
tenon-1.1.3 spec/features/tenon/contacts_spec.rb
tenon-1.1.2 spec/features/tenon/contacts_spec.rb
tenon-1.1.1 spec/features/tenon/contacts_spec.rb
tenon-1.0.76 spec/features/tenon/contacts_spec.rb
tenon-1.0.75 spec/features/tenon/contacts_spec.rb
tenon-1.0.74 spec/features/tenon/contacts_spec.rb
tenon-1.0.73 spec/features/tenon/contacts_spec.rb
tenon-1.0.72 spec/features/tenon/contacts_spec.rb
tenon-1.0.71 spec/features/tenon/contacts_spec.rb
tenon-1.0.70 spec/features/tenon/contacts_spec.rb
tenon-1.0.69 spec/features/tenon/contacts_spec.rb
tenon-1.0.68 spec/features/tenon/contacts_spec.rb
tenon-1.0.67 spec/features/tenon/contacts_spec.rb
tenon-1.0.66 spec/features/tenon/contacts_spec.rb
tenon-1.0.65 spec/features/tenon/contacts_spec.rb