Sha256: 7d469d8b9f76d3b48ce0b60291e27408ee1d4949831d1cbafe5b92e3515d113c

Contents?: true

Size: 2 KB

Versions: 6

Compression:

Stored size: 2 KB

Contents

require 'spec_helper'

module Alchemy
  module Admin

    describe TrashController do

      render_views

      let(:alchemy_page) do
        FactoryGirl.create(:page, :parent_id => Page.rootpage.id)
      end

      let(:element) do
        FactoryGirl.create(:element, :public => false, :page => alchemy_page)
      end

      before do
        sign_in :user, FactoryGirl.create(:admin_user)
        element.trash
      end

      it "should hold trashed elements" do
        get :index, :page_id => alchemy_page.id
        response.body.should have_selector("#element_#{element.id}.element_editor")
      end

      it "should not hold elements that are not trashed" do
        element = FactoryGirl.create(:element, :page => alchemy_page, :public => false)
        get :index, :page_id => alchemy_page.id
        response.body.should_not have_selector("#element_#{element.id}.element_editor")
      end

      context "with unique elements inside the trash" do

        before do
          Element.stub!(:all_definitions_for).and_return([
            {'name' => element.name, 'unique' => true}
          ])
        end

        context "and no unique elements on the page" do

          it "unique elements should be draggable" do
            get :index, :page_id => alchemy_page.id
            response.body.should have_selector("#element_#{element.id}.element_editor.draggable")
          end

        end

        context "and with an unique element on the page" do

          it "unique elements should not be draggable" do
            FactoryGirl.create(:element, :page => alchemy_page, :public => false)
            get :index, :page_id => alchemy_page.id
            response.body.should have_selector("#element_#{element.id}.element_editor.not-draggable")
          end

        end

      end

      context "#clear" do

        it "should destroy all containing elements" do
          post :clear, {:page_id => alchemy_page.id, :format => :js}
          Element.trashed.should be_empty
        end

      end

    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
alchemy_cms-2.6.3 spec/controllers/admin/trash_controller_spec.rb
alchemy_cms-2.6.2.1 spec/controllers/admin/trash_controller_spec.rb
alchemy_cms-2.6.2 spec/controllers/admin/trash_controller_spec.rb
alchemy_cms-2.6.1 spec/controllers/admin/trash_controller_spec.rb
alchemy_cms-2.6.0 spec/controllers/admin/trash_controller_spec.rb
alchemy_cms-2.6.0.rc5 spec/controllers/admin/trash_controller_spec.rb