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
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
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 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
# API is POST {:action => "update", :event => "approve", :id => 3, :document => {:comment => "some comment"}} | |
def update | |
@document = Document.get(params[:id]) | |
if @document.send(params[:event], current_user) | |
@document.update_attributes(params[:document]) | |
end | |
respond_to do |format| | |
# ... | |
# ... | |
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
class Document | |
# .... | |
# ..snip... | |
# .... | |
workflow do | |
state :created do | |
event :scan, :transitions_to => :scanned, :if => Proc.new{|t| !(t.scans.empty?)} | |
event :to_edit, :transitions_to => :editing | |
end | |
state :scanned 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
class Document | |
property :name, Text | |
.... # all the other properties | |
.... | |
property :scanned_on, Date | |
property :tagged_on, Date | |
property :approved_on, Date |
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
it "should move properly between states" do | |
@doc = Factory.build(:taggable, :user => @customer) | |
@doc.scan!(@customer) | |
@doc.scanned?.should == true | |
@doc.digi_document_state_transitions.count.should == 1 | |
expect { @doc.tag_complete!}.should raise_exception # should not 'complete' | |
@doc.completed?.should == false | |
@doc.to_edit!(@customer) # should 'edit' | |
@doc.editing?.should == true | |
@doc.digi_document_state_transitions.count.should == 2 |