This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Party < ActiveRecord::Base | |
has_many :projects, foreign_key: :owner_id | |
has_and_belongs_to_many :projects | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create_table :monthly_transactions do |t| | |
t.integer :jaar | |
t.integer :maand | |
t.integer :cijfer_1 | |
t.decimal :saldo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |