Sha256: 370161a25c55e5dcff598a30983231f8e1e89c7376a345bd1792bc58e7499920

Contents?: true

Size: 1.59 KB

Versions: 50

Compression:

Stored size: 1.59 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')
    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

50 entries across 50 versions & 1 rubygems

Version Path
tenon-1.0.70 spec/features/tenon/comments_spec.rb
tenon-1.0.69 spec/features/tenon/comments_spec.rb
tenon-1.0.68 spec/features/tenon/comments_spec.rb
tenon-1.0.67 spec/features/tenon/comments_spec.rb
tenon-1.0.66 spec/features/tenon/comments_spec.rb
tenon-1.0.65 spec/features/tenon/comments_spec.rb
tenon-1.0.64 spec/features/tenon/comments_spec.rb
tenon-1.0.63 spec/features/tenon/comments_spec.rb
tenon-1.0.62 spec/features/tenon/comments_spec.rb
tenon-1.0.61 spec/features/tenon/comments_spec.rb
tenon-1.0.60 spec/features/tenon/comments_spec.rb
tenon-1.0.59 spec/features/tenon/comments_spec.rb
tenon-1.0.57 spec/features/tenon/comments_spec.rb
tenon-1.0.56 spec/features/tenon/comments_spec.rb
tenon-1.0.55 spec/features/tenon/comments_spec.rb
tenon-1.0.54 spec/features/tenon/comments_spec.rb
tenon-1.0.53 spec/features/tenon/comments_spec.rb
tenon-1.0.52 spec/features/tenon/comments_spec.rb
tenon-1.0.51 spec/features/tenon/comments_spec.rb
tenon-1.0.50 spec/features/tenon/comments_spec.rb