Skip to content

Instantly share code, notes, and snippets.

#
# Cookbook Name:: crontab
# Definition:: crontab
#
#sets the crontab for a user
define :crontab, :username => :root, :filename => nil do
filename = params[:filename]
gem 'rake', '~> 0.8.7'
require 'acceptance/support/acceptance_helper'
feature "Add manual timesheet to payroll report", %q{
In order to tweak the payroll report
As an admin
I want to manually attach timesheets to the report
} do
background do
generate_full_payroll_data
In a lot of languages callbacks are really common. You might call a function
with another function as an argument and at some point
in the body of the called function the callback function gets called. You said
this is done with pointers in C... not sure how
common this is there so bear with me.
# This is (psuedo-code) based on javascript where callbacks are really common
because it's asynchronous (i.e. you often need a callback to be notified when
the function you've called is complete). First two function definitions:
@mikebannister
mikebannister / gist:1216893
Created September 14, 2011 15:34
Rails engine w/ Rspec

NOTE!!!!!!!!! Ended up in trouble going down this path. Followed Rails 3 in Action method instead

generate

rails plugin new importable --dummy-path=spec/dummy --full --mountable && cd importable

in .gitignore change references to test/dummy to spec/dummy (rails bug¿)

spec/dummy/db/*.sqlite3

spec/dummy/log/*.log

scope :search, lambda { |field, value|
return where(field, Product.gender_database_param(value)) if field == :gender
return where(field, Product.status_database_param(value)) if field == :status
where(field, value)
}
Product.search(gender: 'male').search(brand: 'whatever')
namespace :spec do
desc "Run the code examples in spec/acceptance"
RSpec::Core::RakeTask.new(:acceptance => "db:test:prepare") do |t|
t.pattern = "spec/acceptance/**/*_spec.rb"
end
end
module Importable
module Validatable
extend ActiveSupport::Concern
included do
include ActiveModel::Validations
include ActiveModel::Serialization
attr_accessor :attributes
end
scope :before_date, lambda { |date|
where("shift_date >= ?").where(:shift_status => nil)
}
class ApplicationController < ActionController::Base
protect_from_forgery
user_stamp Attachment, Post, Capsule
before_filter :authentication_check
before_filter :capsule_member
before_filter :set_user_time_zone
unless Rails.application.config.consider_all_requests_local
rescue_from Exception, :with => :render_error
rescue_from ActiveRecord::RecordNotFound, :with => :render_not_found