Skip to content

Instantly share code, notes, and snippets.

View jhchabran's full-sized avatar
🧀

Jean-Hadrien Chabran jhchabran

🧀
View GitHub Profile
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe BabysittersController do
integrate_views
context "when not authenticated" do
RestfulActions.for(BabysittersController) do |action|
it "should redirect to root path when accessing ##{action.name}" do
send action.method, action.name, action.args
response.should redirect_to(root_path)
# When deploying for the first time, use vlad:install before vlad:deploy
# 1) vlad:install will copy all files matching .sample* in deploy_to/shared/config
# 2) edit those files and rename them to their final name
# 3) each time you deploy with vlad:deploy, your config files will be symlinked in your application config folder
namespace :vlad do
def shared_config_path
shared_path + '/' + 'config'
end
Rake::Task.define_task(:environment)
load RAILS_ROOT + '/lib/tasks/seed.rake'
Rake.application['db:seed:load'].invoke
module Keywordable
module ClassMethods
def keyword(symbol, proc)
write_inheritable_attribute :keywords, {} unless read_inheritable_attribute :keywords
read_inheritable_attribute(:keywords)[symbol] = proc
end
end
module InstanceMethods
def keywords
# Autocomplete handler for all core controllers.
#----------------------------------------------------------------------------
def auto_complete
@query = params[:auto_complete_query]
@auto_complete = hook(:auto_complete, self, :query => @query, :user => @current_user)
if @auto_complete.empty?
@auto_complete = self.controller_name.classify.constantize.my(:user => @current_user, :limit => 10).search(@query)
else
@auto_complete = @auto_complete.last
end
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Snapshot do
before(:each) do
@observer = PretendObserver.new(@string_io = StringIO.new("","w"))
end
it "should create a snapshot ready to be applied" do
Snapshot.new(:size => "4G", :path => '/dev/vg00/pwet-disk', :name => 'pwet')
end
Usine := Object clone do (
DummyObject := Object clone do (
Suite := Object clone do (
variantName := nil
bodyBlock := nil
eval := method(x,
context := Object clone
context setSlot(variantName, x)
u := Usine clone
u declare("user", user,
user firstname := "John"
user lastname := "Connor"
user age := suite(a, a+2)
)
a := u create("user")
b := u create("user")
Usine := Object clone do (
/* (...) */
create := method (factory,
dummy := factories getSlot(factory) clone
parentProto := dummy protos first
parentProto slotNames foreach(slotName,
value := nil
if(parentProto getSlot(slotName) type == "Suite",
if(suites getSlot(slotName),
Factory.define(:user) do |u|
u.firstname "John"
u.lastname "Connor"
u.sequence(:age) { |i| i ]
end