Sha256: 42fe48cc924f6989dc690781ffb62a2f455839ec1d09864284ffe462ddd43982

Contents?: true

Size: 1.8 KB

Versions: 4

Compression:

Stored size: 1.8 KB

Contents

require 'spec_helper'

describe Kuhsaft::Admin::PagesController do
  render_views

  describe 'should render successfully' do
    before :all do
      # create page with ID=1 if none exists
      Factory.create :page
    end
    
    it '#index' do
      get :index, :locale => :en
      response.should be_success
    end
    
    it '#show' do
      get :show, :id => 1, :locale => :en
      response.should be_success
    end
    
    it '#new' do
      get :new, :locale => :en
      response.should be_success
    end
    
    it '#edit' do
      get :edit, :id => 1, :locale => :en
      response.should be_success
    end
    
    it '#create' do
      # TODO: this is ridiculous. We need to have integration tests(?) for this.
      params = { :kuhsaft_page => { :localized_pages_attributes => { 0 => { :title => 'hi', :locale => :en }}}, :locale => :en }
      post :create, params
      response.should be_redirect
    end
    
    it '#update' do
      # TODO: this is EXTREMELY ridiculous. We need to have integration tests(?) for this.
      page = Kuhsaft::Page.first
      localized_page = page.translation
      params = { 
              :id => page.id, 
              :kuhsaft_page => {
                :localized_pages_attributes => { 
                  0 => {
                    :slug => "hi",
                    :title => "Hi",
                    :id => localized_page.id,
                    :description => '',
                    :locale => 'en',
                    :page_parts_attributes => {
                      0 => {
                        :text => 'some text',
                        :type => 'Kuhsaft::PagePart::Markdown'
                      }
                    }
                  }
                }}, :locale => :en }
      post :update, params
      response.should be_redirect
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kuhsaft-0.1.1 spec/controllers/admin_pages_controller_spec.rb
kuhsaft-0.1.0 spec/controllers/admin_pages_controller_spec.rb
kuhsaft-0.0.8 spec/controllers/admin_pages_controller_spec.rb
kuhsaft-0.0.7 spec/controllers/admin_pages_controller_spec.rb