Sha256: 09b6a299a52e717558e5968497ad1845d86b90d6495d47071d3bbb230d02d120

Contents?: true

Size: 1.11 KB

Versions: 2

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

2 entries across 2 versions & 2 rubygems

Version Path
qbrick-2.5.0.pre spec/lib/page_tree_spec.rb
kuhsaft-2.4.3 spec/lib/page_tree_spec.rb