Sha256: 2db46c375bfce3aed07387ffbc464475b37073684fb2457738581161dd903abd

Contents?: true

Size: 1.65 KB

Versions: 15

Compression:

Stored size: 1.65 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_redirect
        response.should redirect_to(reader_permission_denied_url)
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
radiant-reader-extension-3.0.13 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.11 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.10 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.9 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.8 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.7 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.5 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.4 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.3 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.2 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.1 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.0 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.0.rc4 spec/controllers/site_controller_spec.rb
radiant-reader-extension-3.0.0.rc3 spec/controllers/site_controller_spec.rb
radiant-reader-extension-2.0.0.rc4 spec/controllers/site_controller_spec.rb