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
Test: | |
route_for(:controller => 'users', :action => 'update', :id => '1', :method => :put).should == "/users/1" | |
Failure: | |
Test::Unit::AssertionFailedError in 'UsersController route generation should route users's 'update' action correctly' | |
The recognized options <{"action"=>"show", "id"=>"1", "controller"=>"users"}> did not match <{"action"=>"update", "id"=>"1", "method"=>:put, "controller"=>"users"}>, difference: <{"action"=>"update", "method"=>:put}> | |
Routes: | |
PUT /users/:id {:controller=>"users", :action=>"update"} |
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
<script> | |
var regx = new RegExp(".*#(.*)"); | |
var result = regx.exec(window.location.href); | |
alert(result[1]); | |
</script> |
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 CreateUsers < ActiveRecord::Migration | |
def self.up | |
create_table "users", :options => 'ENGINE=InnoDB DEFAULT CHARSET=utf8', :force => true do |t| | |
t.timestamps | |
... | |
end | |
add_index :users, :login, :unique => true | |
end | |
def self.down |
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
module ActiveRecord | |
module ConnectionAdapters | |
class PostgreSQLAdapter < AbstractAdapter | |
def quote_table_name(name) | |
name | |
end | |
end | |
end | |
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
# Sets up the Rails environment for Cucumber | |
ENV["RAILS_ENV"] = "test" | |
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment') | |
require 'cucumber/rails/world' | |
require 'cucumber/formatters/unicode' # Comment out this line if you don't want Cucumber Unicode support | |
Cucumber::Rails.use_transactional_fixtures | |
require 'webrat' | |
Webrat.configure do |config| |
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
if RAILS_ENV == "development" | |
Paperclip.options[:command_path] = '/opt/local/bin/' | |
Paperclip.options[:magick_home] = '/opt/local/bin/' | |
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
class User < ActiveRecord::Base | |
belongs_to :band | |
has_many :band_fans | |
has_many :favorite_bands, :through => :band_fans, :source => :band | |
end | |
class Band < ActiveRecord::Base |
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
# This file is copied to ~/spec when you run 'ruby script/generate rspec' | |
# from the project root directory. | |
ENV["RAILS_ENV"] ||= 'test' | |
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) | |
require 'spec/autorun' | |
require 'spec/rails' | |
Spec::Runner.configure do |config| | |
# If you're not using ActiveRecord you should remove these | |
# lines, delete config/database.yml and disable :active_record |
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
>> Time.zone | |
=> #<ActiveSupport::TimeZone:0x1976598 @utc_offset=0, @name="UTC", @tzinfo=#<TZInfo::DataTimezone: Etc/UTC>> | |
>> DateTime.now.next_week | |
=> Mon, 25 May 2009 00:00:00 +0100 | |
>> Order.create(:fulfilment_date => DateTime.now.next_week) | |
=> #<Order id: 1, fulfilment_date: "2009-05-24 23:00:00"> |
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
describe "validation" do | |
it 'requires password' do | |
user = Factory.build(:user, :password => nil) | |
user.should_not be_valid | |
user.errors.on(:password).should_not be_nil | |
end | |
it 'requires password confirmation' do | |
user = Factory.build(:user, :password => 'password', :password_confirmation => ' ') |
OlderNewer