Sha256: 398a04bfd2caf1f7b0ee366c2edf383ce59573fc6ed0f0974e6d883a27dec996

Contents?: true

Size: 1.6 KB

Versions: 19

Compression:

Stored size: 1.6 KB

Contents

require 'spec_helper'
include RequestHelpers

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

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

    it 'should see the comment in a list' do
      visit comments_path
      expect(page).to have_content('Test Comment'.upcase)
    end

    it 'should be able to delete the comment' do
      visit comments_path
      click_on 'Delete'
      expect(page).not_to have_content('Test Comment')
    end

    %w(approved).each do |action|
      context "if #{action} is false" do
        it "should be able to toggle #{action} to true" do
          visit comments_path
          within('ul#comments') do
            expect(page).to have_selector("a.toggle.#{action}.false")
            page.find("a.toggle.#{action}").click
            expect(comment.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
            comment.update_attributes(action.to_sym => true)
            visit comments_path
            within('ul#comments') do
              expect(page).to have_selector("a.toggle.#{action}.true")
              page.find("a.toggle.#{action}").click
              expect(comment.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

19 entries across 19 versions & 1 rubygems

Version Path
tenon-1.0.18 spec/features/tenon/comments_spec.rb
tenon-1.0.17 spec/features/tenon/comments_spec.rb
tenon-1.0.16 spec/features/tenon/comments_spec.rb
tenon-1.0.15 spec/features/tenon/comments_spec.rb
tenon-1.0.14 spec/features/tenon/comments_spec.rb
tenon-1.0.13 spec/features/tenon/comments_spec.rb
tenon-1.0.12 spec/features/tenon/comments_spec.rb
tenon-1.0.11 spec/features/tenon/comments_spec.rb
tenon-1.0.10 spec/features/tenon/comments_spec.rb
tenon-1.0.9 spec/features/tenon/comments_spec.rb
tenon-1.0.8 spec/features/tenon/comments_spec.rb
tenon-1.0.7 spec/features/tenon/comments_spec.rb
tenon-1.0.6 spec/features/tenon/comments_spec.rb
tenon-1.0.5 spec/features/tenon/comments_spec.rb
tenon-1.0.4 spec/features/tenon/comments_spec.rb
tenon-1.0.3 spec/features/tenon/comments_spec.rb
tenon-1.0.2 spec/features/tenon/comments_spec.rb
tenon-1.0.1 spec/features/tenon/comments_spec.rb
tenon-1.0 spec/features/tenon/comments_spec.rb