Skip to content

Instantly share code, notes, and snippets.

View ratnikov's full-sized avatar

Dmitry Ratnikov ratnikov

  • wonder.com
  • New York, NY
View GitHub Profile
require 'cgi'
module LoggedInControllerExtension
def self.included(base)
base.extend Setup
base.setup_logged_in
end
module Setup
def setup_logged_in
require 'cgi'
module LoggedInControllerExtension
def self.included(base)
base.extend Setup
base.setup_logged_in
end
module Setup
def setup_logged_in
def uses(source = nil)
block = proc { yield }
klass.inject_csv_source = block_given? ? block : source
end
def para (attributes = {}, &block)
method_missing(:p, attributes, &block)
end
para do
foo = <<-END_PARAGRAPH
Hello there. I love #{input 'inputting VARIOUS things'}. I also get a kick
out of #{code 'coding various things'}. There's such a thrill in
seeing all of the exciting #{output 'output you can get'} from a
well-written program.
def para (attributes = {}, &block)
method_missing(:p, attributes, &block)
end
para do
<<-END_PARAGRAPH
Hello there. I love #{input 'inputting VARIOUS things'}. I also get a kick
out of #{code 'coding various things'}. There's such a thrill in
seeing all of the exciting #{output 'output you can get'} from a
well-written program.
def can_edit?(this_user)
=begin
if can_delete(this_user)
return true
end
if this_user.isadmin
return true
end
if user == this_user
return true
Feature: Beer Donations
In order to donate a beer
A user
Should be signed_in
Background:
Given user@example.com is a user with password "secret"
Scenario: A registered user should be able to donate a beer to another registered user
Given someone@example.com is a user
class AccountsController < ApplicationController
def new
@account = Account.new
end
def create
@account = Account.new(params[:account])
if @account.save
session[:account_id] = @account.id
flash[:notice] = "Thank you for signing up! You are now logged in."
## I seem to have lost my base models - I had obtained them already from pre-existing tables.
Basically, this relates to one table, a model and a subclass, which I thought would be quite short.
class Person < ActiveRecord::Base
has_one :address
has_one :phone
belongs_to :district
def member?
mem # and if you really require true/false: !!mem
@ratnikov
ratnikov / gist:289926
Created January 29, 2010 17:31 — forked from rsl/gist:289924
context "#increment" do
setup { @object.create! }
evaluate { @object.increment! :attribute }
should_change("attribute", :from => 0, :to => 1) { @object.attribute }
end