Skip to content

Instantly share code, notes, and snippets.

Factory.sequence :email do |n|
"user#{n}@example.com"
end
Factory.sequence :username do |n|
"user#{n}"
end
Factory.define :user do |user|
user.email { Factory.next :email }
require File.dirname(__FILE__) + '/../test_helper'
class UserTest < Test::Unit::TestCase
include Clearance::Test::Unit::UserTest
should_allow_mass_assignment_of :username
context "When signing up" do
should_validate_presence_of :username
end
class User < ActiveRecord::Base
include Clearance::App::Models::User
attr_accessible :username
validates_presence_of :username
validates_uniqueness_of :username
end
require File.dirname(__FILE__) + '/../test_helper'
class UsersControllerTest < ActionController::TestCase
include Clearance::Test::Functional::UsersControllerTest
public_context do
context "When getting new User view" do
setup { get :new }
should "display username field" do
require File.dirname(__FILE__) + '/../test_helper'
class SessionsControllerTest < ActionController::TestCase
include Clearance::Test::Functional::SessionsControllerTest
context "Given an email confirmed user" do
setup do
@user = Factory(:user)
@user.confirm_email!
end
context "A user" do
setup do
@user = Factory(:user)
@password = @user.password
end
should "authenticate with username and good credentials" do
assert User.authenticate(@user.username, @password)
assert @user.authenticated?(@password)
end
def self.authenticate(email, password)
user = find(:first, :conditions => ['username = ? OR email = ?', email.to_s.downcase, email.to_s.downcase])
user && user.authenticated?(password) ? user : nil
end
require 'eventmachine'
require 'mq'
module Echo
def initialize(mq)
@mq = mq
end
def receive_data(data)
@mq.queue('log').publish(data)
end
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<style type="text/css">
@media only screen and (max-device-width: 480px) {
table[class=outer] .global-width-670-to-320 {
width: 320px !important;