Sha256: 57b26640500bccb3fc0a0cf1643d4c8e1c56d77ed97d4db156473b532a578034

Contents?: true

Size: 1.6 KB

Versions: 6

Compression:

Stored size: 1.6 KB

Contents

require "spec_helper"

module Refinery
  describe "Crudify" do
    refinery_login_with :refinery_superuser

    describe "xhr_paging", :js => true do
      # Refinery::Admin::UsersController specifies :order => 'username ASC' in crudify
      let(:first_user) { User.order('username ASC').first }
      let(:last_user) { User.order('username ASC').last }
      before do
        FactoryGirl.create :user
        Admin::UsersController.should_receive(:xhr_pageable?).
                               at_least(1).times.and_return(xhr_pageable)
        User.stub(:per_page).and_return(1)
      end

      describe 'when set to true' do
        let(:xhr_pageable) { true }
        it 'should perform ajax paging of index' do
          visit refinery.admin_users_path

          expect(page).to have_selector('li.record', :count => 1)
          expect(page).to have_content(first_user.email)

          within '.pagination' do
            click_link '2'
          end

          expect(page.evaluate_script('jQuery.active')).to eq(1)
          expect(page).to have_content(last_user.email)
        end
      end

      describe 'set to false' do
        let(:xhr_pageable) { false }
        it 'should not perform ajax paging of index' do
          visit refinery.admin_users_path

          expect(page).to have_selector('li.record', :count => 1)
          expect(page).to have_content(first_user.email)

          within '.pagination' do
            click_link '2'
          end

          expect(page.evaluate_script('jQuery.active')).to eq(0)
          expect(page).to have_content(last_user.email)

        end
      end
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
refinerycms-core-2.1.5 spec/features/refinery/admin/xhr_paging_spec.rb
refinerycms-core-2.1.4 spec/features/refinery/admin/xhr_paging_spec.rb
refinerycms-core-2.1.3 spec/features/refinery/admin/xhr_paging_spec.rb
refinerycms-core-2.1.2 spec/features/refinery/admin/xhr_paging_spec.rb
refinerycms-core-2.1.1 spec/features/refinery/admin/xhr_paging_spec.rb
refinerycms-core-2.1.0 spec/features/refinery/admin/xhr_paging_spec.rb