2014-12-04 19:50:02 +01:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: users
|
|
|
|
#
|
2014-12-09 18:56:56 +01:00
|
|
|
# id :integer not null, primary key
|
|
|
|
# created_at :datetime
|
|
|
|
# updated_at :datetime
|
|
|
|
# remember_created_at :datetime
|
2015-03-19 16:22:55 +01:00
|
|
|
# admin :boolean
|
|
|
|
# dagschotel_id :integer
|
|
|
|
# avatar_file_name :string
|
|
|
|
# avatar_content_type :string
|
|
|
|
# avatar_file_size :integer
|
|
|
|
# avatar_updated_at :datetime
|
|
|
|
# orders_count :integer default("0")
|
|
|
|
# koelkast :boolean default("f")
|
2015-09-14 17:52:25 +02:00
|
|
|
# name :string
|
2015-09-02 20:33:35 +02:00
|
|
|
# encrypted_password :string default(""), not null
|
|
|
|
# private :boolean default("f")
|
2014-12-04 19:50:02 +01:00
|
|
|
#
|
|
|
|
|
2015-09-02 20:33:35 +02:00
|
|
|
describe User do
|
|
|
|
before :each do
|
|
|
|
@user = create :user
|
2015-03-03 18:16:05 +01:00
|
|
|
end
|
|
|
|
|
2015-09-02 20:33:35 +02:00
|
|
|
it 'has a valid factory' do
|
|
|
|
expect(@user).to be_valid
|
2015-03-03 18:16:05 +01:00
|
|
|
end
|
2015-09-21 15:54:56 +02:00
|
|
|
|
|
|
|
############
|
|
|
|
# FIELDS #
|
|
|
|
############
|
|
|
|
|
|
|
|
describe 'fields' do
|
|
|
|
describe 'avatar' do
|
|
|
|
it 'should be present' do
|
|
|
|
@user.avatar = nil
|
|
|
|
expect(@user).to_not be_valid
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'orders_count' do
|
|
|
|
it 'should automatically cache the number of orders' do
|
|
|
|
expect{ create :order, user: @user }.to change{ @user.reload.orders_count }.by(1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-11-06 14:46:59 +01:00
|
|
|
end
|