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
# video.rb | |
class Video < ActiveRecord::Base | |
has_many :categorizations | |
has_many :categories, through: :categorizations | |
end | |
# category.rb | |
class Category < ActiveRecord::Base | |
has_many :categorizations | |
has_many :videos, through: :categorizations |
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
cask 'dash2' do | |
version '2.2.6' | |
sha256 'a7de5e00528611f86d1024164b1b5d536ce039344b6ca3c211918c7458f7e412' | |
url "https://kapeli.com/downloads/v#{version.major}/Dash.zip" | |
name 'Dash' | |
homepage 'https://kapeli.com/dash' | |
auto_updates true |
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
# This is a skeleton for testing models including examples of validations, callbacks, | |
# scopes, instance & class methods, associations, and more. | |
# Pick and choose what you want, as all models don't NEED to be tested at this depth. | |
# | |
# I'm always eager to hear new tips & suggestions as I'm still new to testing, | |
# so if you have any, please share! | |
# | |
# @kyletcarlson | |
# | |
# This skeleton also assumes you're using the following gems: |
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 Klass < ActiveRecord::Base | |
# | |
# Attributes | |
# | |
# | |
# Constants & Enums | |
# |
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
# fixed: Elasticsearch::Transport::Transport::Errors::ServiceUnavailable: [503] | |
# https://hugotunius.se/2015/06/22/elasticsearch-falkiness-in-tests.html | |
# https://medium.com/@thetron/dealing-with-503-errors-when-testing-elasticsearch-integration-in-rails-ec7a5f828274#.ex6quza03 | |
# https://github.com/elastic/elasticsearch-ruby/issues/181#issuecomment-112781924 | |
# spec/support/elasticsearch_cleaner.rb | |
RSpec.configure do |config| | |
config.before(:each, :es => true) do | |
ElasticsearchModel.create_index!(:force => true) | |
ElasticsearchModel.client.cluster.health(wait_for_status: 'yellow') |
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
# spec/support/database_cleaner.rb | |
RSpec.configure do |config| | |
config.before(:suite) do | |
DatabaseCleaner.clean_with(:truncation) | |
end | |
config.before(:each) do | |
DatabaseCleaner.strategy = :transaction | |
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
# Returns the Gravatar (http://gravatar.com) for the given user. | |
def gravatar_for(user, options = {size: 40}) | |
gravatar_id = Digest::MD5::hexdigest(user.email.downcase) | |
size = options[:size] | |
gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}?s=#{size}" | |
image_tag(gravatar_url, alt: user.full_name) | |
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
jQuery.fn.elementAfter = function(other) { | |
for(i = 0; i < this.length - 1; i++) { | |
if (this[i]() == other) { | |
return jQuery(this[i + 1]()); | |
} | |
} | |
}; | |
jQuery.fn.elementBefore = function(other) { | |
if (this.length > 0) { |
NewerOlder