Merge branch 'master' of github.com:ZeusWPI/Tab
This commit is contained in:
commit
a868cadd26
2 changed files with 14 additions and 1 deletions
|
@ -10,7 +10,14 @@
|
|||
#
|
||||
|
||||
class Client < ActiveRecord::Base
|
||||
before_create :generate_key
|
||||
|
||||
def transactions
|
||||
Transaction.where(origin: name)
|
||||
end
|
||||
|
||||
private
|
||||
def generate_key
|
||||
self.key = SecureRandom.base64(16) unless self.key
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,5 +12,11 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Client, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
it "should have a valid factory" do
|
||||
expect(create(:client)).to be_valid
|
||||
end
|
||||
|
||||
it "should generate a key" do
|
||||
expect(create(:client).key).to be_present
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue