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 Game | |
include Mongoid::Document | |
def self.my_method | |
puts "test" | |
end | |
end | |
class Deer < Game | |
my_method |
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
specify 'with product_quantity greater than associated product quantity' do | |
Factory(:order, | |
:product => Factory(:product, :quantity => 10), | |
:product_quantity => 11 | |
).should have(1).error_on(:product_quantity) | |
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 Order < ActiveRecord::Base | |
belongs_to :product | |
belongs_to :user | |
validates_presence_of :user, :product, :product_quantity | |
validates_numericality_of :product_quantity, | |
:only_integer => true, :greater_than => 0, :less_than_or_equal_to => 10000, :allow_blank => true | |
validate :enough_product_quantity, | |
# if does not work |
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
describe 'POST create' do | |
context 'with valid params' do | |
before(:each) { User.any_instance.stub!(:valid?).and_return(true) } | |
it 'creates new user and redirects to the home page with a notice' do | |
post :create, :user => Factory.attributes_for(:user, :username => 'dude') | |
assigns[:user].should be_persisted | |
assigns[:user].username.should eq('dude') | |
flash[:notice].should_not be_nil | |
response.should redirect_to(root_url) | |
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 LocatorController < ApplicationController | |
def autocomplete | |
require 'net/http' | |
require 'net/https' | |
url = URI.parse 'https://maps.googleapis.com/maps/api/place/autocomplete/json?language=pl&input=Polichno&sensor=false&key=ABQIAAAAHyX2ujLFqkeXszJQ65ZPbhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTCcRPSPSwcyYGhNTuA3d46XxgyQg' | |
http = Net::HTTP.new(url.host, url.port) | |
http.use_ssl = true | |
req = Net::HTTP::Get.new(url.path) | |
res = http.request(req) | |
puts res |
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
new Ajax.Request('https://maps.googleapis.com/maps/api/place/autocomplete/json', { | |
method: 'get', | |
parameters: { | |
language: 'pl', | |
input: 'Polichno', | |
sensor: true, | |
key: 'ABQIAAAAHyX2ujLFqkeXszJQ65ZPbhQCULP4XOMyhPd8d_NrQQEO8sT8XBQKE5E92FkCP2ATUaYPiLb3YFfVzg' | |
}, | |
onSuccess: function(transport, json) { | |
alert(json ? Object.inspect(json) : 'no JSON object'); |
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
def self.roots | |
where(:parent_id => nil) | |
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
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril. | |
# It is recommended to regenerate this file in the future when you upgrade to a | |
# newer version of cucumber-rails. Consider adding your own code to a new file | |
# instead of editing this one. Cucumber will automatically load all features/**/*.rb | |
# files. | |
require 'uri' | |
require 'cgi' | |
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths")) |
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
= form_for(@movie) do |f| | |
= f.label :title | |
= f.text_field :title | |
= f.label :release_year | |
= f.select :release_year, (1900..2011).to_a.map(&:to_s) | |
- @genres.each do |genre| | |
%label | |
=h genre.name | |
= check_box_tag 'genres[]', genre.id | |
= f.submit 'Save' |
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 MoviesController < ApplicationController | |
def index | |
end | |
def new | |
@movie = Movie.create | |
@genres = Genre.all | |
end | |
def create |
NewerOlder