View controller_macros.rb
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
# frozen_string_literal: true | |
module ControllerMacros | |
def login_user | |
before(:each) do | |
@request.env['devise.mapping'] = Devise.mappings[:user] | |
current_collaborator = FactoryBot.create(:account_collaborator, :admin) | |
current_account = current_collaborator.account |
View http_url_validator.rb
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
# frozen_string_literal: true | |
module Validators | |
class HttpUrlValidator < ActiveModel::EachValidator | |
GENERIC_URI_FORMAT = /^((ftp|http|https):\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/ix | |
def validate_each(record, attribute, value) | |
uri = parse_uri(value) | |
record.errors.add(attribute, :bad_uri, options) unless uri | |
end |
View checkbox_dynamic_selection_with_foundation_dropdown.html.erb
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
<script type="text/javascript"> | |
// JAVASCRIPT | |
function bind_bulk_toggle(resource_toggle_id, form_id) { | |
return $(resource_toggle_id).click(function() { | |
if ($(resource_toggle_id).is(':checked')) { | |
$(form_id + ' input:checkbox').prop('checked', true); | |
return $(form_id + ' input:checkbox').each(function() { | |
return $(this).val($(this).parents('tr').find('.selected_ids').val()); | |
}); |
View en.yml
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
en: | |
errors: &errors | |
messages: | |
bad_uri: is an invalid url | |
bad_protocol: must start with %{protocols} | |
activemodel: | |
errors: | |
<<: *errors | |
activerecord: | |
errors: |
View email_validation_service.rb
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 'resolv.rb' | |
class EmailValidationService | |
DOMAIN_LENGTH = 255 | |
LOCAL_LENGTH = 64 | |
LOCAL_PART_SPECIAL_CHAR = /[\!\#\$\%\&\'\*\-\/\=\?\+\-\^\_\`\{\|\}\~]/ | |
def self.valid_email_format?(email) | |
begin |
View bulk_checkbox_selection.html.erb
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
<script type="text/javascript"> | |
// JAVASCRIPT | |
window.bind_bulk_resources_checkbox_toggle = function() { | |
return $('#bulk_toggle_checkbox').click(function() { | |
if ($('#bulk_toggle_checkbox').is(':checked')) { | |
$('#bulk_form input:checkbox').prop('checked', true); | |
return $('#bulk_form input:checkbox').each(function() { | |
return $(this).val($(this).parents('tr').find('.selected_ids').val()); |
View custom_logger.rb
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 Logging | |
class CustomLogger | |
DEFAULTS = { | |
level: :info | |
} | |
LEVELS = %w(debug info warn error fatal unknown).map(&:to_sym) | |
def self.log(*tags, **params) | |
level = determine_log_level(**params) |