문제

이 사양을 어떻게 작동시킬 수 있습니까?

실제 결과:

expected: [#<Department id: 1, user_id: 1,  ...
     got: [#<Department id: 1, user_id: "1",  ...

이것은 내 사양입니다.

 describe "GET department list" do
    before(:each) do
      @request.env["devise.mapping"] = Devise.mappings[:user]
      @current_user = Fabricate(:user_with_active_account_and_departments) 
      # creates a user with 10 departments
      @current_user.confirm! 
      # or set a confirmed_at inside the factory.
      # Only necessary if you are using the confirmable module
      sign_in @current_user
    end

    it "assigns all departments of current_user to @departments" do
      get :departments, {id: @current_user}
      assigns(:users_departments).should eq (@current_user.departments)
    end
  end
도움이 되었습니까?

해결책

열 유형을 변경하십시오 departments 문자열에서 정수까지 테이블 :

def self.up
  change_column :departments, :user_id, :integer
end

def self.down
  change_column :departments, :user_id, :string
end
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top