Sha256: 211add916e9758906a14ed87d0d5a7534c86eb6303f0379722afdfd3e7c8e054

Contents?: true

Size: 1.22 KB

Versions: 13

Compression:

Stored size: 1.22 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(dashboard_url)
    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

13 entries across 13 versions & 1 rubygems

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