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 Person | |
attr_accessor :name, :role | |
def initialize(name, role) | |
@name, @role = name, role | |
end | |
# options is a Hash with the following keys | |
# :to -> the role to set to |
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 UserStatistics | |
# This class is responsible for aggregating User data into meaningful reports | |
attr_accessor :user | |
# | |
# | |
# ... snip ... | |
# |
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 Search | |
ALLOWED_MODELS = [:receipt, :business_card, :other_document] | |
SEARCH_COLS = { | |
:receipt => [:title,:organisation], | |
:business_card => [:first_name,:last_name,:organisation,:designation,:locality,:city,:pincode, :email, :twitter, :mobile, :notes], | |
:other_document => [:title,:notes] | |
} | |
NON_SEARCH_KEYS = [:tags, :q, :model, :all, :only, :from, :to, :by, :page] |
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
ItemsController | |
DELETE destroy | |
destroys the requested item | |
redirects to the items list | |
GET show | |
assigns the requested item as @item | |
GET new | |
assigns a new item as @item | |
POST create | |
with valid params |
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
ItemsController | |
unauthorised | |
does not edit | |
does not new | |
does not index | |
does not show | |
does not update | |
authorised | |
index |
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
ReceiptsController | |
unauthenticated user | |
should not be able to access index page | |
POST create | |
does not create a new Receipt | |
customer user | |
GET index | |
assigns all users documents as @documents | |
searches properly |
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
def is_valid_loan_product(method) | |
loan_attr = self.send(method) | |
return [false, "No #{method} specified"] if not loan_attr or loan_attr==="" | |
return [false, "No loan product chosen"] unless self.loan_product | |
product = self.loan_product | |
#Checking if the loan adheres to minimum and maximums of the loan product | |
{:min => :minimum, :max => :maximum}.each{|k, v| | |
product_attr = product.send("#{k}_#{method}") | |
if method==:interest_rate | |
product_attr = product_attr.to_f/100.round(6) |
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
before :all do | |
@loan_product = LoanProduct.new | |
@loan_product.name = "LP1" | |
@loan_product.max_amount = 1000 | |
@loan_product.min_amount = 1000 | |
@loan_product.max_interest_rate = 100 | |
@loan_product.min_interest_rate = 0.1 | |
@loan_product.installment_frequency = :weekly | |
@loan_product.max_number_of_installments = 25 | |
@loan_product.min_number_of_installments = 25 |