Sha256: 7d015d33a3f6ab89315505b5c0c0fe21c1fd5b2f8932af4e10cfd97d2bb62a7e

Contents?: true

Size: 1.76 KB

Versions: 10

Compression:

Stored size: 1.76 KB

Contents

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

describe ReaderActivationsController 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 a correct activation" do
    before do
      @newreader = readers(:inactive)
      put :update, :id => @newreader.id, :activation_code => @newreader.perishable_token
      @reader = Reader.find_by_name('Inactive')
    end

    it "should activate the reader" do
      @reader.activated?.should be_true
      @reader.activated_at.should be_close((Time.now).utc, 1.minute)
    end

    it "should redirect to the dashboard" do
      response.should be_redirect
      response.should redirect_to(reader_dashboard_url)
    end
  end

  describe "with a homed group member" do
    before do
      @newreader = readers(:homed)
      put :update, :id => @newreader.id, :activation_code => @newreader.perishable_token
      @reader = Reader.find_by_name('Homed')
    end

    it "should activate the reader" do
      @reader.activated?.should be_true
      @reader.activated_at.should be_close((Time.now).utc, 1.minute)
    end

    it "should redirect to the right group home page" do
      response.should be_redirect
      response.should redirect_to(pages(:parent).path)
    end
  end

  describe "with an incorrect activation" do
    before do
      @newreader = readers(:inactive)
      put :update, :id => @newreader.id, :activation_code => 'down perishcope'
    end
    
    it "should render the show page" do
      response.should be_success
      response.should render_template("show")
    end

    it "should not flash an error" do
      flash[:error].should be_nil
    end
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
radiant-reader-extension-3.0.38 spec/controllers/reader_activations_controller_spec.rb
radiant-reader-extension-3.0.37 spec/controllers/reader_activations_controller_spec.rb
radiant-reader-extension-3.0.36 spec/controllers/reader_activations_controller_spec.rb
radiant-reader-extension-3.0.35 spec/controllers/reader_activations_controller_spec.rb
radiant-reader-extension-3.0.33 spec/controllers/reader_activations_controller_spec.rb
radiant-reader-extension-3.0.32 spec/controllers/reader_activations_controller_spec.rb
radiant-reader-extension-3.0.31 spec/controllers/reader_activations_controller_spec.rb
radiant-reader-extension-3.0.30 spec/controllers/reader_activations_controller_spec.rb
radiant-reader-extension-3.0.29 spec/controllers/reader_activations_controller_spec.rb
radiant-reader-extension-3.0.28 spec/controllers/reader_activations_controller_spec.rb