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
| Thor::Base.shell = Thor::Shell::Color | |
| require 'yaml' | |
| require 'rails/version' | |
| RAILS6 = Rails::VERSION::MAJOR == 6 | |
| def truthy?(statement) | |
| val = ask(statement) | |
| ['y', 'yes', ''].include?(val) | |
| 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 User < ApplicationRecord | |
| has_many :todo_lists | |
| def self.set_current_user(id) | |
| @_current_user = find(id) | |
| end | |
| # Avoid a DB query each time we need the currently logged in user | |
| def self.current_user | |
| @_current_user |
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 extract_emails_from_mailing_list(mailing_list) | |
| mailing_list.entries.map(&:email).keep_if(&:present) | |
| 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 'rails_helper' | |
| RSpec.describe IncomeReportQuery do | |
| let!(:user) { create(:user) } | |
| describe '#resolve' do | |
| let(:test_scope) { instance_double(ActiveRecord::Relation) } | |
| let(:result) { query.resolve } | |
| context 'filtering by nothing' do |
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 FamilyRegistrationForm | |
| include ActiveModel::Model | |
| attribute_reader :user | |
| attribute_reader :relative | |
| attribute :user_email, String | |
| attribute :user_name, String | |
| attribute :relative_email, String | |
| attribute :relative_name, String |
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
| Verifying my Blockstack ID is secured with the address 12tucjxEQNZo8qZTFXsYir4CJuXXxVetio https://explorer.blockstack.org/address/12tucjxEQNZo8qZTFXsYir4CJuXXxVetio |
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 < ApplicationRecord | |
| attr_accessor :from_comic_con_campaign | |
| validates :twitter_username, presence: true, if: -> { from_comic_con_campaign } | |
| validates :d_and_d_handle, presence: true, if: -> { from_comic_con_campaign } | |
| validates :password, presence: true, confirmation: true | |
| validates :first_name, :last_name, :email, presence: true | |
| validates :email, format: { with: /@/, message: "is invalid" } | |
| 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
| def parse_token(token) | |
| return nil if token.nil? | |
| if token.match(/[2, 4, 6, 8]/) | |
| 1 | |
| else | |
| 0 | |
| end | |
| 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
| sql_time_query_mapping = { | |
| :hour => 'HOUR', | |
| :day => 'DATE', | |
| :week => 'YEARWEEK', | |
| :moth => 'MONTH' | |
| } |