Skip to content

Instantly share code, notes, and snippets.

[user]
name = Arthur Klepchukov
email = [email protected]
[alias]
co = checkout
st = status
ci = commit
a = add
b = branch
d = diff
require 'test_helper'
class PatientTest < ActiveSupport::TestCase
def test_should_create_patient
assert_difference 'Patient.count' do
patient = create_patient
assert !patient.new_record?, "#{patient.errors.full_messages.to_sentence}"
end
end
# Here's a sample from one of my controllers:
def create
@feed_search = FeedSearch.new(params[:feed_search])
@feed_search.feeds = params[:feeds].delete_if{|url| url==""}.map{|url| Feed.find_or_initialize_by_url(url)}
@user = (logged_in?) ? current_user : User.find_by_email_or_register(params[:feed_search][:email])
# search needs activation if user isn't logged in
@feed_search.state = (logged_in?) ? 'active' : 'pending'
class Idea < ActiveRecord::Base
has_many :comments
acts_as_rateable
after_save :default_rating
validates_presence_of :name
validates_presence_of :body
test "an idea should start with a rating of 3" do
idea = create_idea
idea.save!
assert idea.rating == 3
end