This file contains hidden or 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_relative 'user' | |
| describe User, "#roles" do | |
| it "returns 'User' for a new user" do | |
| user = User.new | |
| user.roles.include?("User").should be(true) | |
| end | |
| it "returns 'User' and 'Moderator' if user is a moderator" do | |
| user = User.new |
This file contains hidden or 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 | |
| ROLES = %w[Administrator Editor Moderator User] | |
| end |
This file contains hidden or 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 'open-uri' | |
| require 'test/unit' | |
| class Spin | |
| def self.winning_number | |
| URI.parse('http://roulette.engineyard.com').read.gsub(/[^\d]/,'').to_i | |
| end | |
| end | |
| class StraightBet |
This file contains hidden or 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 'open-uri'; | |
| def straight_bet(bet,bid); (open('http://roulette.engineyard.com').read.gsub(/[^\d]/,'')==bet.to_s) ? 35*bid : 0; end |
This file contains hidden or 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 UsersController < ApplicationController | |
| respond_to :html, :xml | |
| def index | |
| @users = User.all | |
| respond_with(@user) | |
| end | |
| def show |
This file contains hidden or 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
| # Generate our local key | |
| openssl genrsa 2048 > local.key | |
| # Create the self-signed certificate for all *.dev addresses | |
| openssl req -new -x509 -nodes -sha1 -days 3650 -key local.key << ANSWERS > local.cert | |
| US | |
| IL | |
| Chicago | |
| Myself | |
| Me |
This file contains hidden or 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
| var https = require('https'); | |
| var fs = require('fs'); | |
| var options = { | |
| key: fs.readFileSync('local.key'), | |
| cert: fs.readFileSync('local.pem') | |
| }; | |
| https.createServer(options, function (req, res) { | |
| res.writeHead(200); |
This file contains hidden or 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 Place < ActiveRecord::Base | |
| after_save :create_simplegeo_record | |
| private | |
| def create_simplegeo_record | |
| begin | |
| record = SimpleGeo::Record.new({ | |
| :id => self.id, |
This file contains hidden or 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
| - title "Rate Calculator" | |
| .block#tab-container | |
| #tab-container.secondary-navigation | |
| %ul.wat-cf | |
| %li{class: (current_user.has_role?(:check_role) ? "first" : nil)}= link_to "First Tab", "#tab-one" | |
| %li= link_to "Second Tab", "#tab-two" | |
| %li= link_to "Third Tab", "#tab-three" | |
| .content | |
| #tab-one | |
| %h2 First Tab |
This file contains hidden or 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 Approval | |
| attr_accessor :status | |
| def method_missing(meth, *args, &blk) | |
| method_name = meth.to_s | |
| if method_name =~ /\?$/ | |
| self.status.downcase.eql? method_name.gsub(/\?$/,'') | |
| else | |
| super | |
| end | |
| end |
OlderNewer