This file contains 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
require 'cgi' | |
module LoggedInControllerExtension | |
def self.included(base) | |
base.extend Setup | |
base.setup_logged_in | |
end | |
module Setup | |
def setup_logged_in |
This file contains 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
require 'cgi' | |
module LoggedInControllerExtension | |
def self.included(base) | |
base.extend Setup | |
base.setup_logged_in | |
end | |
module Setup | |
def setup_logged_in |
This file contains 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 uses(source = nil) | |
block = proc { yield } | |
klass.inject_csv_source = block_given? ? block : source | |
end |
This file contains 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 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. |
This file contains 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 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. |
This file contains 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 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 |
This file contains 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
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 |
This file contains 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 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." |
This file contains 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
## 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 |
This file contains 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
context "#increment" do | |
setup { @object.create! } | |
evaluate { @object.increment! :attribute } | |
should_change("attribute", :from => 0, :to => 1) { @object.attribute } | |
end |
OlderNewer