Created
October 4, 2011 19:33
-
-
Save rdavila/1262556 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class RegistrationsController < Devise::RegistrationsController | |
| before_filter :check_presence_of_plan_id_and_campaign_id, :only => [ :new, :create ] | |
| protected | |
| def check_presence_of_plan_id_and_campaign_id | |
| redirect_to plans_url if cookies[:plan_id].blank? || cookies[:campaign_id].blank? | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'spec_helper' | |
| describe RegistrationsController, 'create the first user account' do | |
| context "when there isn't plan_id in the cookies" do | |
| it 'should redirect to the plans page' do | |
| cookies[:campaign_id] = '1' | |
| get :new | |
| response.should redirect_to(plans_url) | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Pfr::Application.routes.draw do | |
| resources :campaigns | |
| resources :plans | |
| devise_for :users, :controllers => { :registrations => 'registrations' }, :skip => [ :sessions ] | |
| as :user do | |
| get "/sign_in" => "devise/sessions#new", :as => :new_user_session | |
| post "/sign_in" => "devise/sessions#create", :as => :user_session | |
| delete "/sign_out" => "devise/sessions#destroy", :as => :destroy_user_session | |
| get "/users/cancel" => "devise/registrations#cancel", :as => :cancel_user_registrations | |
| post "/users" => "registrations#create", :as => :user_registration | |
| get "/sign_up" => "registrations#new", :as => :new_user_registration | |
| get "/users/edit" => "devise/registrations#edit", :as => :edit_user_registration | |
| put "/users" => "devise/registrations#update" | |
| delete "/users" => "devise/registrations#destroy" | |
| end | |
| root :to => "home#index" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'spork' | |
| require 'devise/test_helpers' | |
| RSpec.configure do |config| | |
| config.before(:suite) do | |
| DatabaseCleaner.strategy = :truncation | |
| end | |
| config.before(:each) do | |
| DatabaseCleaner.start | |
| end | |
| config.after(:each) do | |
| DatabaseCleaner.clean | |
| end | |
| config.include Devise::TestHelpers, :type => :controller | |
| end | |
| ENV["RAILS_ENV"] ||= 'test' | |
| require File.expand_path("../../config/environment", __FILE__) | |
| require 'rspec/rails' | |
| # Requires supporting ruby files with custom matchers and macros, etc, | |
| # in spec/support/ and its subdirectories. | |
| #Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} | |
| RSpec.configure do |config| | |
| config.mock_with :rspec | |
| end | |
| ActiveSupport::Dependencies.clear | |
| ActiveRecord::Base.instantiate_observers | |
| FactoryGirl.factories.clear | |
| Pfr::Application.reload_routes! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment