user test

This commit is contained in:
benji 2015-10-28 23:34:03 +01:00
parent f5e6a6e7bf
commit b5782b13d8
6 changed files with 45 additions and 10 deletions

View file

@ -10,6 +10,5 @@
= content_tag :span, product.name
= content_tag :small, euro(product.price)
= f.counter :count, min: 0, max: product.stock, skip_label: true, wrapper_class: "input-group", class: "row_counter", data: { price: f.object.product.price_cents }
= f.input :product_id
-# = f.fields_for :product do |product|
-# / This is needed for haml
= f.fields_for :product do |product|
/ This is needed for haml

View file

@ -0,0 +1,5 @@
class AddDefaultFalseToAdminUsers < ActiveRecord::Migration
def change
change_column :users, :admin, :boolean, default: false
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150919091214) do
ActiveRecord::Schema.define(version: 20151028223229) do
create_table "barcodes", force: :cascade do |t|
t.integer "product_id"
@ -75,7 +75,7 @@ ActiveRecord::Schema.define(version: 20150919091214) do
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "remember_created_at"
t.boolean "admin"
t.boolean "admin", default: false
t.integer "dagschotel_id"
t.string "avatar_file_name"
t.string "avatar_content_type"

View file

@ -24,8 +24,9 @@ require 'identicon'
FactoryGirl.define do
factory :user do
name { Faker::Name.name }
avatar { Identicon.data_url_for name }
name { Faker::Name.name }
avatar { Identicon.data_url_for name }
private { false }
factory :admin do
admin true

View file

@ -127,9 +127,9 @@ describe Product do
end
end
###########
# SCOPE #
###########
############
# SCOPES #
############
describe 'for sale' do
it 'should return non-deleted products' do

View file

@ -45,5 +45,35 @@ describe User do
expect{ create :order, user: @user }.to change{ @user.reload.orders_count }.by(1)
end
end
describe 'admin' do
it 'should be false by default' do
expect(@user.reload.admin).to be false
end
end
describe 'koelkast' do
it 'should be false by default' do
expect(@user.reload.koelkast).to be false
end
end
end
############
# SCOPES #
############
describe 'scopes' do
it 'members should return members' do
create :koelkast
user = create :user
expect(User.members).to eq([@user, user])
end
it 'publik should return publik members' do
user = create :user
create :user, private: true
expect(User.publik).to eq([@user, user])
end
end
end