Sha256: 0df282e7e23f23dcd4b21a4316abdf34d345288edbbd14e224444789bad6b638

Contents?: true

Size: 1.04 KB

Versions: 19

Compression:

Stored size: 1.04 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) { {"0"=>{"id"=>"1", "children"=>{"0"=>{"id"=>"2"}}},
                 "1"=>{"id"=>"3"}}}

    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)
        @page1.reload.position.should == 0
        @page2.reload.position.should == 0
        @page3.reload.position.should == 1
      end

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

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
kuhsaft-2.2.6 spec/lib/page_tree_spec.rb
kuhsaft-2.2.5 spec/lib/page_tree_spec.rb
kuhsaft-2.2.4 spec/lib/page_tree_spec.rb
kuhsaft-2.2.3 spec/lib/page_tree_spec.rb
kuhsaft-2.2.2 spec/lib/page_tree_spec.rb
kuhsaft-2.2.1 spec/lib/page_tree_spec.rb
kuhsaft-2.2.0 spec/lib/page_tree_spec.rb
kuhsaft-2.1.2 spec/lib/page_tree_spec.rb
kuhsaft-2.1.1 spec/lib/page_tree_spec.rb
kuhsaft-2.1.0 spec/lib/page_tree_spec.rb
kuhsaft-1.8.6 spec/lib/page_tree_spec.rb
kuhsaft-1.8.5 spec/lib/page_tree_spec.rb
kuhsaft-2.0.3 spec/lib/page_tree_spec.rb
kuhsaft-2.0.2 spec/lib/page_tree_spec.rb
kuhsaft-1.8.4 spec/lib/page_tree_spec.rb
kuhsaft-1.8.1 spec/lib/page_tree_spec.rb
kuhsaft-2.0.1 spec/lib/page_tree_spec.rb
kuhsaft-2.0.0 spec/lib/page_tree_spec.rb
kuhsaft-1.8.0 spec/lib/page_tree_spec.rb