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
Failures: | |
1) UserSessionsController#create with correct credentials with device_id and device_type set someone else is logged in with the same devic | |
e_id adds AddDeviceToken to the queue | |
Failure/Error: expect{ | |
expected result to have changed by 1, but was changed by 0 | |
# ./spec/controllers/user_sessions_controller_spec.rb:91:in `block (6 levels) in <top (required)>' | |
Finished in 1.45 seconds (files took 2.33 seconds to load) | |
13 examples, 1 failure |
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
Schemas | |
An update_call of the item_classification | |
Processing ItemClassificationsController#update (for 127.0.0.1 at 2015-03-23 11:15:54) [PUT] |
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
params = {:id=>"5", :jurisdiction=>{:place_attributes=>{:name=>"Allen County15", :short_name=>"Allen County15", :id=>"5"}}} | |
@jurisdiction = PlaceEntity.jurisdictions.excluding_unassigned.find(params[:id]) | |
@jurisdiction.place | |
@jurisdiction.update_attributes(params[:jurisdiction]) | |
@jurisdiction.place.valid? |
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 AddIndexToLineItems < ActiveRecord::Migration | |
def change | |
add_index :line_items, [:user_id, :product_id], unique: true | |
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
require 'benchmark' | |
hsh = {} | |
1000.times {|i| hsh[i.to_s] = i.succ.to_s} | |
Benchmark.bm do |x| | |
x.report("Hash[]") {1000.times{Hash[hsh.values.zip(hsh.keys)]}} | |
x.report("invert") {1000.times{hsh.invert}} | |
x.report("each_with_object") {1000.times{hsh.each_with_object({}){|(k,v),h| h[v] = k}}} | |
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
<% content_for :title do %> | |
<%= @game.SportsLeagueName %>: <%= team_logo @game.away_team %> <%= @game.away_team %> at <%= @game.home_team %>" | |
<% end %> | |
<%= team_logo @game.away_team %> | |
<div> | |
<% if @game.SportsLeagueName == 'NFL' %> | |
<%= image_tag "http://151986650d2f98828025-63e4acfff05fd55acad2fbee57a1d69b.r75.cf2.rackcdn.com/#{@game.AwayTeamID}.png" %> | |
AT | |
<%= image_tag "http://151986650d2f98828025-63e4acfff05fd55acad2fbee57a1d69b.r75.cf2.rackcdn.com/#{@game.HomeTeamID}.png" %> |
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
module ApplicationHelper | |
def title(*parts) | |
unless parts.empty? | |
parts << t(:website) | |
content_for(:title) do | |
parts.join(' - ') | |
end | |
end | |
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
class FollowUpVisitGardensController < ApplicationController | |
def new | |
#1st you retrieve the group thanks to params[:group_id] | |
#2nd you build a new comment | |
@group = Group.find(params[:group_id]) | |
@gardener= Gardener.find(params[:gardener_id]) | |
@follow_up_visit_garden= FollowUpVisitGarden.new | |
if @gardener.valid? | |
render "new" |
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
def add_emojify_and_kramdown(text) | |
markdowned = Kramdown::Document.new(text).to_html | |
raw(emojify(markdowned)) | |
end | |
def emojify(text) | |
text.to_str.gsub(/:([a-z0-9\+\-_]+):/) do |match| | |
if emoji = Emoji.find_by_alias($1) | |
%Q{<img alt="$1" class="emoji" src="#{ image_path(emoji.image_filename) }">} |
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
task :postcode_import => :environment do | |
puts "\n\n Importing PostCodes" | |
lat_long_res = [] | |
CSV.foreach "lib/data/example.csv" do |row| | |
if row[0].include? " " | |
postcode = row[0] | |
else | |
postcode = row[0][0..3] + " " + row[4..-1] | |
end | |
easting = row[1].to_i |