Sha256: fc231b08f03457d4cce0514e4e3a518260912bca2e7a4ff0da42b19348582262

Contents?: true

Size: 1.64 KB

Versions: 22

Compression:

Stored size: 1.64 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe SiteController do
  dataset :readers
  
  before do
    controller.stub!(:request).and_return(request)
    Page.current_site = sites(:test) if defined? Site
    request.env["HTTP_REFERER"] = 'http://test.host/referer!'
  end
    
  describe "with no reader" do
    before do
      logout_reader
    end
    
    describe "getting an ungrouped page" do
      it "should render the page" do
        get :show_page, :url => ''
        response.should be_success
        response.body.should == 'Hello world!'
      end
    end
    
    describe "getting a grouped page" do
      it "should redirect to login" do
        get :show_page, :url => 'parent/'
        response.should be_redirect
        response.should redirect_to(reader_login_url)
      end
    end
  end
  
  describe "with a reader" do
    before do
      login_as_reader(:normal)
    end

    describe "getting an ungrouped page" do
      it "should render the page" do
        get :show_page, :url => ''
        response.should be_success
        response.body.should == 'Hello world!'
      end
    end
    
    describe "getting a grouped page to which she has access" do
      it "should render the page" do
        get :show_page, :url => 'parent/'
        response.should be_success
        response.body.should == 'Parent body.'
      end
    end
    
    describe "getting a grouped page to which she doesn't have access" do
      it "should redirect to the permission-denied page" do
        get :show_page, :url => 'news/'
        response.should be_success
        response.should render_template('shared/not_allowed')
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
radiant-reader-extension-3.0.38 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.37 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.36 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.35 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.33 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.32 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.31 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.30 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.29 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.28 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.27 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.26 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.25 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.24 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.23 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.20 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.19 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.18 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.17 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.16 spec/controllers/site_controller_spec.rb