user test
This commit is contained in:
parent
f5e6a6e7bf
commit
b5782b13d8
6 changed files with 45 additions and 10 deletions
|
@ -10,6 +10,5 @@
|
||||||
= content_tag :span, product.name
|
= content_tag :span, product.name
|
||||||
= content_tag :small, euro(product.price)
|
= 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.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|
|
||||||
-# = f.fields_for :product do |product|
|
/ This is needed for haml
|
||||||
-# / This is needed for haml
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddDefaultFalseToAdminUsers < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
change_column :users, :admin, :boolean, default: false
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# 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|
|
create_table "barcodes", force: :cascade do |t|
|
||||||
t.integer "product_id"
|
t.integer "product_id"
|
||||||
|
@ -75,7 +75,7 @@ ActiveRecord::Schema.define(version: 20150919091214) do
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.datetime "remember_created_at"
|
t.datetime "remember_created_at"
|
||||||
t.boolean "admin"
|
t.boolean "admin", default: false
|
||||||
t.integer "dagschotel_id"
|
t.integer "dagschotel_id"
|
||||||
t.string "avatar_file_name"
|
t.string "avatar_file_name"
|
||||||
t.string "avatar_content_type"
|
t.string "avatar_content_type"
|
||||||
|
|
|
@ -26,6 +26,7 @@ FactoryGirl.define do
|
||||||
factory :user do
|
factory :user do
|
||||||
name { Faker::Name.name }
|
name { Faker::Name.name }
|
||||||
avatar { Identicon.data_url_for name }
|
avatar { Identicon.data_url_for name }
|
||||||
|
private { false }
|
||||||
|
|
||||||
factory :admin do
|
factory :admin do
|
||||||
admin true
|
admin true
|
||||||
|
|
|
@ -127,9 +127,9 @@ describe Product do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
###########
|
############
|
||||||
# SCOPE #
|
# SCOPES #
|
||||||
###########
|
############
|
||||||
|
|
||||||
describe 'for sale' do
|
describe 'for sale' do
|
||||||
it 'should return non-deleted products' do
|
it 'should return non-deleted products' do
|
||||||
|
|
|
@ -45,5 +45,35 @@ describe User do
|
||||||
expect{ create :order, user: @user }.to change{ @user.reload.orders_count }.by(1)
|
expect{ create :order, user: @user }.to change{ @user.reload.orders_count }.by(1)
|
||||||
end
|
end
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue