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 "an idea should start with a rating of 3" do | |
idea = create_idea | |
idea.save! | |
assert idea.rating == 3 | |
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 Idea < ActiveRecord::Base | |
has_many :comments | |
acts_as_rateable | |
after_save :default_rating | |
validates_presence_of :name | |
validates_presence_of :body |
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
# 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' | |
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 '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 |
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
[user] | |
name = Arthur Klepchukov | |
email = [email protected] | |
[alias] | |
co = checkout | |
st = status | |
ci = commit | |
a = add | |
b = branch | |
d = diff |
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 Site < ActiveRecord::Base | |
has_many :pages | |
belongs_to :account | |
validates_presence_of :url | |
validates_format_of :url, :with => URI.regexp(['http', 'https']) | |
validates_presence_of :account_id | |
validates_associated :account |
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 User, "is created and activated properly" do | |
before(:each) do | |
@user = User.new | |
end | |
describe "new user from development environment" do | |
before(:each) do | |
@user.context = :dev | |
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
test 'should delete all pages when deleted' do | |
base_url = "http://google.com/" | |
site = nil | |
assert_difference "Site.count", 1 do | |
site = create_site(:url => base_url) | |
end | |
page_urls = %w(maps movies alerts) | |
assert_difference "Page.count", page_urls.size do | |
page_urls.each do |page_url| |
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
[user] | |
name = Arthur Klepchukov | |
email = [email protected] | |
[alias] | |
co = checkout | |
st = status | |
ci = commit | |
a = add | |
b = branch | |
d = diff |
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
.css({ | |
'width':'300px', | |
'position':'absolute', | |
'top':'15px', | |
'right':'15px', | |
'border':'1px solid black', | |
'padding':'5px' | |
}) |
OlderNewer