Skip to content

Instantly share code, notes, and snippets.

View durexlw's full-sized avatar

durexlw durexlw

View GitHub Profile
class Party < ActiveRecord::Base
has_many :projects, foreign_key: :owner_id
has_and_belongs_to_many :projects
end
create_table :monthly_transactions do |t|
t.integer :jaar
t.integer :maand
t.integer :cijfer_1
t.decimal :saldo
require 'test_helper'
class Wqm < ActiveSupport::TestCase
setup do
@wqm = Wqm.new
end
describe "when asking the first day of last month" do
it "should return the first day of last month" do
@durexlw
durexlw / 01Factory
Last active February 16, 2016 12:44
FactoryGirl.define do
factory :contract do
sequence(:persnr) { |n| "#{n}" }
sequence(:naam) { |n| "naam #{n}" }
sequence(:voornaam) { |n| "voornaam #{n}" }
sequence(:maand) { |n| n }
sequence(:maand_teller) { |n| n }
jaar 2015
end
end
@durexlw
durexlw / 01contract.rb
Last active February 16, 2016 10:49
Trying to test scope with factorygirl
# model/contract.rb
class Contract < ActiveRecord::Base
scope :koppen_per_maand, -> { select("jaar, maand, count(persnr) as aantal_koppen").group("maand_teller") }
def self.serialize_for_graph
ContractSerializer.koppen_per_maand(self.koppen_per_maand).to_json
end
end