简体   繁体   中英

FactoryGirl not creating data in view

So this is my Factory:

    FactoryGirl.define do
     factory :member do       
       email 'admin@admin.com'
       password 'rootroot'    
       first_name 'Rinholds'  
       last_name 'Jordan'     
       expiration Time.local(2015, 6, 21, 15, 13, 0)
       start_date Time.local(2015, 4, 21, 15, 13, 0)
       role 2                 
     end
  end

This is my spec:

   require 'rails_helper'

   describe DashboardController, type: :controller do

     it 'should display chart', js: true do
       member = create(:member)  
       member.save!           
       member.confirm         

       binding.pry            
       visit '/'              

     end
   end 

This is my root_path():

     body
       = yield
     = Member.first.email
~            

When i run spec it returns undefined method `email' for nil:NilClass in view.

When i put binding pry in view, and run Member.all it returns empty array!

How is that posible? How to force factorygirl to create real database data?!?

-- edit -- This is the controller, althout it doesnt even get there, because of devise login page authorized_member!

   class DashboardController < ApplicationController
     before_filter :authenticate_member!

     def index
       day_statistics = Statistics::DayStatistics.new(current_member)
       @charts = day_statistics.domain_charts
     end
   end

Resolved the problem by installing databsecleaner! Member data now shows in controller and views!!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM