Skip to content

Instantly share code, notes, and snippets.

View khadzhinov's full-sized avatar

Aleksandr Khadzhinov khadzhinov

View GitHub Profile
# frozen_string_literal: true
describe Calendar::Icalendar do
subject :ical do
Calendar::Icalendar.new(account,
start: start,
stop: stop,
filter: filter&.params || {},
filter_name: filter&.name).get_items.to_ical
end
@khadzhinov
khadzhinov / base_controller
Created August 18, 2018 12:56
API base controller
module Api
module V3
class BaseController < ActionController::Base
include Mixins::Audit
respond_to :json
before_filter :authenticate, except: :api_key
before_filter :set_user_time_zone, except: :api_key
doorkeeper_for :all, except: :api_key, unless: -> { request.params['api_key'].present? }
attr_accessor :current_user, :account, :parent_resource
# == Schema Information
#
# Table name: devices
#
# id :integer not null, primary key
# user_id :integer
# token :string(255)
# device_type :string(255)
# name :string(255)
# os :string(255)
require 'spec_helper'
describe Organization do
it { should have_many(:organization_bank_accounts).dependent(:destroy) }
it { should have_many(:organization_branches).dependent(:destroy) }
it { should have_many(:departments).dependent(:destroy) }
it { should have_many(:employees).dependent(:destroy) }
it { should have_many(:reports).dependent(:destroy) }
it { should have_many(:payments).dependent(:destroy) }
it { should have_many(:events).dependent(:destroy) }
class Organization < VersionableModel
belongs_to :user
belongs_to :country
belongs_to :organization_economic_type
has_many :purchases
has_many :all_subscriptions, :class_name => "Subscription", :dependent => :destroy
has_many :subscriptions, -> { where {(activated_at != nil) & (valid_through >= my{Time.zone.today}) & (valid_from <= my{Time.zone.today})}.order("valid_from ASC") }
has_one :organization_responsible_person, :dependent => :destroy , :inverse_of => :organization