Merge branch 'master' of github.com:ZeusWPI/Tab

This commit is contained in:
Tom Naessens 2015-09-08 14:25:26 +02:00
commit a868cadd26
2 changed files with 14 additions and 1 deletions

View file

@ -10,7 +10,14 @@
# #
class Client < ActiveRecord::Base class Client < ActiveRecord::Base
before_create :generate_key
def transactions def transactions
Transaction.where(origin: name) Transaction.where(origin: name)
end end
private
def generate_key
self.key = SecureRandom.base64(16) unless self.key
end
end end

View file

@ -12,5 +12,11 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe Client, type: :model do 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 end