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
if (typeof console === "undefined" || typeof console.log === "undefined") { | |
console = { | |
log: function() { | |
} | |
}; | |
} |
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 'spec_helper' | |
describe User do | |
describe "#password_reset" do | |
let(:site) { create :site } | |
let(:user) { create :user } | |
it "creates a password_reset_token" do | |
expect{ | |
user.send_password_reset(site) |
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 'spec_helper' | |
describe Template do | |
let(:site) { create :site } | |
let(:template) { create :template, name: "ABCD", tpl_type: 'tpl', site: site } | |
subject { template } | |
# this also tests downcasing names | |
its(:tpl_name) { should eql('abcd.tpl') } | |
its(:dirname) { should eql("#{Rails.root}/public/sites/#{template.site_id}/templates") } |
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
# 1 | |
List.fetch_by_slug(@site, 'mys-slug') | |
# 2 - adding query methods on the collection | |
@site.lists.fetch_by_slug('my-slug') | |
# How achieved | |
class Site < ActiveRecord::Base | |
has_many :lists do | |
def fetch_by_slug(slug) |
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
CREATE TRIGGER update_task_counters | |
AFTER INSERT OR UPDATE OR DELETE ON tasks | |
FOR EACH ROW EXECUTE PROCEDURE update_task_counters(); |
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 AddCountTriggers < ActiveRecord::Migration | |
def up | |
execute %q{ | |
CREATE OR REPLACE FUNCTION update_task_counters (taskid integer) | |
RETURNS void AS $$ | |
BEGIN | |
update tasks set | |
users_count = coalesce((select count(9) from taskships where task_id = taskid), 0) | |
where id = taskid; | |
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
alter proc search (@query nvarchar(100)) | |
/* | |
** Purpose: Search for a specific value in all columns in all tables | |
** Notes: | |
set statistics time on | |
exec q_sys_search 'q_' | |
set statistics time off | |
** Revision History: | |
** yyyy-mm-dd Author Comments | |
** ---------- -------------- -------------------- |
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
# Scenario för att välja produkt | |
# Resurser som behövs är: | |
# @card_products | |
# Scenario för produkten 'Period buss' | |
# Resurser som behövs är: | |
# @product |
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
namespace :attachments do | |
task :migrate_to_s3 => :environment do | |
require 'aws/s3' | |
# Load credentials | |
s3_options = YAML.load_file(File.join(Rails.root, 'config/s3.yml')).symbolize_keys | |
bucket = s3_options[:bucket_name] | |
# Establish S3 connection |
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
# requests/edit_post_spec.rb | |
require 'spec_helper' | |
feature 'editing a post', js: true do | |
let(:post) { create :post } | |
let(:user) { post.creator } | |
before { sign_in user } |