Merge branch 'master' of github.com:ZeusWPI/Tab
This commit is contained in:
commit
b993c99d50
6 changed files with 36 additions and 12 deletions
|
@ -11,8 +11,6 @@
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :client do
|
factory :client do
|
||||||
name "MyString"
|
name { Faker::Lorem.word }
|
||||||
key "MyString"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,11 +14,10 @@
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :transaction do
|
factory :transaction do
|
||||||
debtor nil
|
association :debtor, factory: :user
|
||||||
creditor nil
|
association :creditor, factory: :user
|
||||||
amount 1
|
amount { rand(100) }
|
||||||
origin "MyString"
|
origin 'FactoryGirl'
|
||||||
message "MyString"
|
message { Faker::Lorem.sentence }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,7 +12,11 @@
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :user do
|
factory :user do
|
||||||
|
name { Faker::Internet.user_name }
|
||||||
|
|
||||||
|
factory :penning do
|
||||||
|
penning true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,5 +15,24 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Transaction, type: :model do
|
RSpec.describe Transaction, type: :model do
|
||||||
pending "add some examples to (or delete) #{__FILE__}"
|
it "has a valid factory" do
|
||||||
|
expect(create(:transaction)).to be_valid
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "cache" do
|
||||||
|
before :each do
|
||||||
|
@user = create(:user)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should update creditor cache" do
|
||||||
|
trans = build(:transaction, creditor: @user, amount: 10)
|
||||||
|
expect {trans.save!}.to change {@user.balance}.by(10)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should update debtor cache" do
|
||||||
|
trans = build(:transaction, debtor: @user, amount: 10)
|
||||||
|
expect {trans.save!}.to change {@user.balance}.by(-10)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,5 +13,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe User, type: :model do
|
RSpec.describe User, type: :model do
|
||||||
pending "add some examples to (or delete) #{__FILE__}"
|
it "has a valid factory" do
|
||||||
|
expect(create(:user)).to be_valid
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,9 @@
|
||||||
# users commonly want.
|
# users commonly want.
|
||||||
#
|
#
|
||||||
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
||||||
|
require 'factory_girl'
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
|
config.include FactoryGirl::Syntax::Methods
|
||||||
# rspec-expectations config goes here. You can use an alternate
|
# rspec-expectations config goes here. You can use an alternate
|
||||||
# assertion/expectation library such as wrong or the stdlib/minitest
|
# assertion/expectation library such as wrong or the stdlib/minitest
|
||||||
# assertions if you prefer.
|
# assertions if you prefer.
|
||||||
|
|
Loading…
Reference in a new issue