Sha256: 98e0f2313ab51c1206f915f6eeca07baea9dc5677a5644c77c559b789e902a2e

Contents?: true

Size: 1.11 KB

Versions: 10

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'
require_relative '../../lib/kuhsaft/page_tree'
require_relative '../../app/models/kuhsaft/page'

# TODO: THESE SPECS ONLY WORK WHEN THE FULL SUITE IS RUN. FIX THAT!

module Kuhsaft
  describe PageTree do
    let(:page_tree) do
      {
        '0' => { 'id' => '1', 'children' => { '0' => { 'id' => '2' } } },
        '1' => { 'id' => '3' }
       }
    end

    before :each do
      @page1 = FactoryGirl.create(:page, id: 1, position: 10)
      @page2 = FactoryGirl.create(:page, id: 2, position: 10)
      @page3 = FactoryGirl.create(:page, id: 3, position: 10)
    end

    describe 'update' do
      it 'sets the correct position of the root nodes' do
        PageTree.update(page_tree)
        expect(@page1.reload.position).to eq(0)
        expect(@page2.reload.position).to eq(0)
        expect(@page3.reload.position).to eq(1)
      end

      it 'sets the correct parent attribute for the nodes' do
        PageTree.update(page_tree)
        @page1.reload.parent_id.should be_nil
        expect(@page2.reload.parent_id).to eq(1)
        @page3.reload.parent_id.should be nil
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
kuhsaft-2.4.2 spec/lib/page_tree_spec.rb
kuhsaft-2.4.1 spec/lib/page_tree_spec.rb
kuhsaft-2.4.0 spec/lib/page_tree_spec.rb
kuhsaft-2.3.6 spec/lib/page_tree_spec.rb
kuhsaft-2.3.5 spec/lib/page_tree_spec.rb
kuhsaft-2.3.4 spec/lib/page_tree_spec.rb
kuhsaft-2.3.3 spec/lib/page_tree_spec.rb
kuhsaft-2.3.2 spec/lib/page_tree_spec.rb
kuhsaft-2.3.1 spec/lib/page_tree_spec.rb
kuhsaft-2.3.0 spec/lib/page_tree_spec.rb