Sha256: 2d5c73b7db6125b4d0a58e19158eca2a2d74fd563ab4bde0b36be23524d81aa1

Contents?: true

Size: 1.4 KB

Versions: 14

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'

describe Alchemy::Admin::ContentsController do

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

  describe '#create' do

    let(:element) { FactoryGirl.create(:element, :name => 'headline') }

    it "should create a content via ajax post" do
      length_before = element.contents.length
      post :create, {:content => {:element_id => element.id, :name => 'headline'}, :format => :js}
      element.contents.reload
      element.contents.length.should == length_before + 1
    end

  end

  describe '#update' do

    it "should update a content via ajax" do
      @element = FactoryGirl.create(:element, :create_contents_after_create => true)
      post :update, {:id => @element.contents.find_by_name('intro').id, :content => {:body => 'Peters Petshop'}, :format => :js}
      @element.ingredient('intro').should == "Peters Petshop"
    end

  end

  describe "#order" do

    context "with content_ids in params" do

      before(:each) do
        @element = FactoryGirl.create(:element, :create_contents_after_create => true)
      end

      it "should reorder the contents" do
        content_ids = @element.contents.essence_texts.collect(&:id)
        post :order, {:content_ids => content_ids.reverse, :format => :js}
        response.status.should == 200
        @element.contents.essence_texts.collect(&:id).should == content_ids.reverse
      end

    end

  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
alchemy_cms-2.6.3 spec/controllers/admin/contents_controller_spec.rb
alchemy_cms-2.6.2.1 spec/controllers/admin/contents_controller_spec.rb
alchemy_cms-2.6.2 spec/controllers/admin/contents_controller_spec.rb
alchemy_cms-2.6.1 spec/controllers/admin/contents_controller_spec.rb
alchemy_cms-2.6.0 spec/controllers/admin/contents_controller_spec.rb
alchemy_cms-2.6.0.rc5 spec/controllers/admin/contents_controller_spec.rb
alchemy_cms-2.5.3.1 spec/controllers/admin/contents_controller_spec.rb
alchemy_cms-2.5.3 spec/controllers/admin/contents_controller_spec.rb
alchemy_cms-2.5.2.2 spec/controllers/admin/contents_controller_spec.rb
alchemy_cms-2.5.2.1 spec/controllers/admin/contents_controller_spec.rb
alchemy_cms-2.5.2 spec/controllers/admin/contents_controller_spec.rb
alchemy_cms-2.5.1 spec/controllers/admin/contents_controller_spec.rb
alchemy_cms-2.5.0 spec/controllers/admin/contents_controller_spec.rb
alchemy_cms-2.5.0.rc3 spec/controllers/admin/contents_controller_spec.rb