Rspec and Devise: Не ўдалося знайсці сапраўднае адлюстраванне для # <Карыстальніка

з дапамогай RSpec і Devise, я атрымліваю памылку адлюстравання.

  1) BusinessesController GET index sets @new_vacation
     Failure/Error: sign_in @user
     RuntimeError:
       Could not find a valid mapping for #
     # ./spec/controllers/businesses_controller_spec.rb:10:in `block (2 levels) in '

Падобна, адказ можа быць тут Тэсты RSpec з devise: не ўдалося знайсці сапраўднае адлюстраванне , але я не магу яго атрымаць.

Любыя ідэі, я сапраўды сапсаваны! Дзякуй.


routes.rb

  constraints(SubdomainRoute) do

    # SIGN IN
    devise_for :accounts, :controllers => {
                                                      :sessions => "users/accounts/sessions",
                                                      :confirmations =>  "users/accounts/confirmations" },
                                                      :class_name => 'Admin' do
      get "accounts/sign_in", :to => "users/accounts/sessions#new"

      get "accounts/sign_up", :to => "users/devise/registrations#new"
      get "accounts/signedup", :to => "users/devise/confirmations#signedup", :as => "signedup_registration"
    end
end

admin.rb

class Admin < User
  validates_associated :business
end

user.rb

class User < ActiveRecord::Base
  belongs_to :business
  accepts_nested_attributes_for :business

  # TODO get lockable working -- failed_attempts is incrementing in db
  devise :database_authenticatable, :registerable, :confirmable, :lockable,
         :recoverable, :rememberable, :trackable, :validatable
end

factories.rb

FactoryGirl.define do

  Factory.define :business do |b|
  end

  Factory.define :business_main, :parent => :business do |b|
    b.business_name "Ann's Salon"
    b.address_line1 "123 Main Street"
    b.address_line2 ""
    b.city "Portland"
    b.state "Oregon"
    b.zip "97211"
  end

  factory :admin do
    confirmed_at Time.now

    factory :admin_one do
      association :business, :factory => :business_one
      email
      password 'please'
      admin true
    end
  end
end

business_controller_spec.rb

require 'spec_helper'

describe BusinessesController do

  before (:each) do
    @business = Factory(:business_one)
    @user     = User.find_by_business_id(@business.id)
    sign_in @user
  end

  describe "GET index" do

    let(:describe_action) { get :index }

    it "sets @new_vacation" do
      BusinessVacation.should_receive(:new)
      get :index
    end
  end

end

0
задан Community 23 May 2017 в 11:45
поделиться