repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/integrations/mongoid/versions.rb | lib/state_machine/integrations/mongoid/versions.rb | module StateMachine
module Integrations #:nodoc:
module Mongoid
version '2.x' do
def self.active?
::Mongoid::VERSION =~ /^2\./
end
def define_state_initializer
define_helper :instance, <<-end_eval, __FILE__, __LINE__ + 1
def initialize(*)
... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/integrations/sequel/versions.rb | lib/state_machine/integrations/sequel/versions.rb | module StateMachine
module Integrations #:nodoc:
module Sequel
version '2.8.x - 3.23.x' do
def self.active?
!defined?(::Sequel::MAJOR) || ::Sequel::MAJOR == 2 || ::Sequel::MAJOR == 3 && ::Sequel::MINOR <= 23
end
def define_state_initializer
define_helper ... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/integrations/data_mapper/observer.rb | lib/state_machine/integrations/data_mapper/observer.rb | module StateMachine
module Integrations #:nodoc:
module DataMapper
# Adds support for creating before/after/around/failure transition
# callbacks within a DataMapper observer. These callbacks behave very
# similar to hooks during save/update/destroy/etc., but with the following
# modifica... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/integrations/data_mapper/versions.rb | lib/state_machine/integrations/data_mapper/versions.rb | module StateMachine
module Integrations #:nodoc:
module DataMapper
version '0.9.x - 0.10.x' do
def self.active?
::DataMapper::VERSION =~ /^0\.\d\./ || ::DataMapper::VERSION =~ /^0\.10\./
end
def pluralize(word)
::Extlib::Inflection.pluralize(word.to_s)
... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/integrations/active_model/observer.rb | lib/state_machine/integrations/active_model/observer.rb | module StateMachine
module Integrations #:nodoc:
module ActiveModel
# Adds support for invoking callbacks on ActiveModel observers with more
# than one argument (e.g. the record *and* the state transition). By
# default, ActiveModel only supports passing the record into the
# callbacks.
... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/integrations/active_model/observer_update.rb | lib/state_machine/integrations/active_model/observer_update.rb | module StateMachine
module Integrations #:nodoc:
module ActiveModel
# Represents the encapsulation of all of the details to be included in an
# update to state machine observers. This allows multiple arguments to
# get passed to an observer method (instead of just a single +object+)
# whi... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/integrations/active_model/locale.rb | lib/state_machine/integrations/active_model/locale.rb | {:en => {
:activemodel => {
:errors => {
:messages => {
:invalid => StateMachine::Machine.default_messages[:invalid],
:invalid_event => StateMachine::Machine.default_messages[:invalid_event] % ['%{state}'],
:invalid_transition => StateMachine::Machine.default_messages[:invalid_transi... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/integrations/active_model/versions.rb | lib/state_machine/integrations/active_model/versions.rb | module StateMachine
module Integrations #:nodoc:
module ActiveModel
version '2.x' do
def self.active?
!defined?(::ActiveModel::VERSION) || ::ActiveModel::VERSION::MAJOR == 2
end
def define_validation_hook
define_helper :instance, <<-end_eval, __FILE__, __... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/integrations/active_record/locale.rb | lib/state_machine/integrations/active_record/locale.rb | filename = "#{File.dirname(__FILE__)}/../active_model/locale.rb"
translations = eval(IO.read(File.expand_path(filename)), binding, filename)
translations[:en][:activerecord] = translations[:en].delete(:activemodel)
# Only ActiveRecord 2.3.5+ can pull i18n >= 0.1.3 from system-wide gems (and
# therefore possibly have I... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/integrations/active_record/versions.rb | lib/state_machine/integrations/active_record/versions.rb | module StateMachine
module Integrations #:nodoc:
module ActiveRecord
version '2.x - 3.0.x' do
def self.active?
::ActiveRecord::VERSION::MAJOR == 2 || ::ActiveRecord::VERSION::MAJOR == 3 && ::ActiveRecord::VERSION::MINOR == 0
end
def define_static_state_initializer
... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/yard/templates.rb | lib/state_machine/yard/templates.rb | require 'yard'
YARD::Templates::Engine.register_template_path File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
| ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/yard/handlers.rb | lib/state_machine/yard/handlers.rb | module StateMachine
module YARD
# YARD custom handlers for integrating the state_machine DSL with the
# YARD documentation system
module Handlers
end
end
end
Dir["#{File.dirname(__FILE__)}/handlers/*.rb"].sort.each do |path|
require "state_machine/yard/handlers/#{File.basename(path)}"
end
| ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/yard/handlers/event.rb | lib/state_machine/yard/handlers/event.rb | module StateMachine
module YARD
module Handlers
# Handles and processes #event
class Event < Base
handles method_call(:event)
def process
if owner.is_a?(StateMachine::Machine)
handler = self
statement = self.statement
names = extra... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/yard/handlers/transition.rb | lib/state_machine/yard/handlers/transition.rb | module StateMachine
module YARD
module Handlers
# Handles and processes #transition
class Transition < Base
handles method_call(:transition)
def process
if [StateMachine::Machine, StateMachine::Event, StateMachine::State].include?(owner.class)
options = {... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/yard/handlers/state.rb | lib/state_machine/yard/handlers/state.rb | module StateMachine
module YARD
module Handlers
# Handles and processes #state
class State < Base
handles method_call(:state)
def process
if owner.is_a?(StateMachine::Machine)
handler = self
statement = self.statement
names = extra... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/yard/handlers/base.rb | lib/state_machine/yard/handlers/base.rb | module StateMachine
module YARD
module Handlers
# Handles and processes nodes
class Base < ::YARD::Handlers::Ruby::Base
private
# Extracts the value from the node as either a string or symbol
def extract_node_name(ast)
case ast.type
when :symbol_lite... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/yard/handlers/machine.rb | lib/state_machine/yard/handlers/machine.rb | require 'tempfile'
module StateMachine
module YARD
module Handlers
# Handles and processes #state_machine
class Machine < Base
handles method_call(:state_machine)
namespace_only
# The generated state machine
attr_reader :machine
def process
... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/yard/templates/default/class/html/setup.rb | lib/state_machine/yard/templates/default/class/html/setup.rb | require 'tempfile'
# Define where state machine descriptions will be rendered
def init
super
sections.place(:state_machine_details).before(:children)
end
# Renders state machine details in the main content of the class's documentation
def state_machine_details
erb(:state_machines) if state_machines
end
# Gets ... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/core_ext/class/state_machine.rb | lib/state_machine/core_ext/class/state_machine.rb | require 'state_machine/macro_methods'
Class.class_eval do
include StateMachine::MacroMethods
end
| ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
cesarferreira/dryrun | https://github.com/cesarferreira/dryrun/blob/3cdd6e89b25b10bcc97394a2537bf4725a98780a/spec/dryrun_spec.rb | spec/dryrun_spec.rb | require 'spec_helper'
| ruby | MIT | 3cdd6e89b25b10bcc97394a2537bf4725a98780a | 2026-01-04T15:48:46.137022Z | false |
cesarferreira/dryrun | https://github.com/cesarferreira/dryrun/blob/3cdd6e89b25b10bcc97394a2537bf4725a98780a/spec/github_spec.rb | spec/github_spec.rb | require 'spec_helper'
require 'dryrun/github'
describe '# Github' do
context 'URL validity' do
it 'URL should be valid' do
url = 'https://github.com/cesarferreira/android-helloworld'
github = Dryrun::Github.new(url)
expected = 'https://github.com/cesarferreira/android-helloworld.git'
exp... | ruby | MIT | 3cdd6e89b25b10bcc97394a2537bf4725a98780a | 2026-01-04T15:48:46.137022Z | false |
cesarferreira/dryrun | https://github.com/cesarferreira/dryrun/blob/3cdd6e89b25b10bcc97394a2537bf4725a98780a/spec/spec_helper.rb | spec/spec_helper.rb | require 'dryrun'
RSpec.configure do |config|
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.
config.expect_with :rspec do |expectations|
# This option will default to `true` in RSpec 4. It makes ... | ruby | MIT | 3cdd6e89b25b10bcc97394a2537bf4725a98780a | 2026-01-04T15:48:46.137022Z | false |
cesarferreira/dryrun | https://github.com/cesarferreira/dryrun/blob/3cdd6e89b25b10bcc97394a2537bf4725a98780a/lib/dryrun.rb | lib/dryrun.rb | require 'colorize'
require 'tmpdir'
require 'fileutils'
require 'dryrun/github'
require 'dryrun/version'
require 'dryrun/android_project'
require 'dryrun/install_application_command'
require 'dryrun/test_application_command'
require 'dryrun/device'
require 'highline/import'
require 'openssl'
require 'open3'
require 'o... | ruby | MIT | 3cdd6e89b25b10bcc97394a2537bf4725a98780a | 2026-01-04T15:48:46.137022Z | false |
cesarferreira/dryrun | https://github.com/cesarferreira/dryrun/blob/3cdd6e89b25b10bcc97394a2537bf4725a98780a/lib/dryrun/version.rb | lib/dryrun/version.rb | module Dryrun
VERSION = '1.3.2'.freeze
end
| ruby | MIT | 3cdd6e89b25b10bcc97394a2537bf4725a98780a | 2026-01-04T15:48:46.137022Z | false |
cesarferreira/dryrun | https://github.com/cesarferreira/dryrun/blob/3cdd6e89b25b10bcc97394a2537bf4725a98780a/lib/dryrun/dryrun_utils.rb | lib/dryrun/dryrun_utils.rb | require 'open-uri'
require 'dryrun/version'
require 'open3'
module Dryrun
class DryrunUtils
attr_accessor :sdk
attr_accessor :device
def self.execute(command)
is_success = system command
unless is_success
puts "\n\n======================================================\n\n"
... | ruby | MIT | 3cdd6e89b25b10bcc97394a2537bf4725a98780a | 2026-01-04T15:48:46.137022Z | false |
cesarferreira/dryrun | https://github.com/cesarferreira/dryrun/blob/3cdd6e89b25b10bcc97394a2537bf4725a98780a/lib/dryrun/install_application_command.rb | lib/dryrun/install_application_command.rb | require_relative 'dryrun_utils'
require_relative 'android_utils'
module Dryrun
class InstallApplicationCommand
def run(builder, package, launcher_activity, custom_module, flavour, device)
execute_line = get_execution_command_line(package, launcher_activity)
builder.clean
if device.nil?
... | ruby | MIT | 3cdd6e89b25b10bcc97394a2537bf4725a98780a | 2026-01-04T15:48:46.137022Z | false |
cesarferreira/dryrun | https://github.com/cesarferreira/dryrun/blob/3cdd6e89b25b10bcc97394a2537bf4725a98780a/lib/dryrun/github.rb | lib/dryrun/github.rb | require 'tmpdir'
require 'fileutils'
require 'uri'
require_relative 'dryrun_utils'
module Dryrun
class Github
def initialize(url)
@base_url = sanitize_url(url)
@destination = destination
end
def sanitize_url(url)
url = url.split('?').first
url.chop! if url.end_with? '/'
ur... | ruby | MIT | 3cdd6e89b25b10bcc97394a2537bf4725a98780a | 2026-01-04T15:48:46.137022Z | false |
cesarferreira/dryrun | https://github.com/cesarferreira/dryrun/blob/3cdd6e89b25b10bcc97394a2537bf4725a98780a/lib/dryrun/gradle_adapter.rb | lib/dryrun/gradle_adapter.rb | require_relative 'dryrun_utils'
module Dryrun
class GradleAdapter
def initialize(builder)
@builder = builder
end
def clean
DryrunUtils.execute("#{@builder} clean")
end
def run_android_tests(custom_module, flavour)
if custom_module
puts "#{@builder} :#{custom_module}:c... | ruby | MIT | 3cdd6e89b25b10bcc97394a2537bf4725a98780a | 2026-01-04T15:48:46.137022Z | false |
cesarferreira/dryrun | https://github.com/cesarferreira/dryrun/blob/3cdd6e89b25b10bcc97394a2537bf4725a98780a/lib/dryrun/test_application_command.rb | lib/dryrun/test_application_command.rb | require_relative 'dryrun_utils'
require_relative 'android_utils'
module Dryrun
class TestApplicationCommand
def run(builder, package, launcher_activity, custom_module, flavour, device)
execute_line = get_execution_command_line(package)
builder.clean
if device.nil?
puts 'No devices pic... | ruby | MIT | 3cdd6e89b25b10bcc97394a2537bf4725a98780a | 2026-01-04T15:48:46.137022Z | false |
cesarferreira/dryrun | https://github.com/cesarferreira/dryrun/blob/3cdd6e89b25b10bcc97394a2537bf4725a98780a/lib/dryrun/manifest_parser.rb | lib/dryrun/manifest_parser.rb | require 'oga'
module Dryrun
class ManifestParser
attr_accessor :package, :launcher_activity
def initialize(manifest_file)
doc = Oga.parse_xml(manifest_file)
@package = get_package(doc)
@launcher_activity = get_launcher_activity(doc)
end
def get_package(doc)
doc.xpath('//m... | ruby | MIT | 3cdd6e89b25b10bcc97394a2537bf4725a98780a | 2026-01-04T15:48:46.137022Z | false |
cesarferreira/dryrun | https://github.com/cesarferreira/dryrun/blob/3cdd6e89b25b10bcc97394a2537bf4725a98780a/lib/dryrun/android_project.rb | lib/dryrun/android_project.rb | require 'oga'
require 'fileutils'
require 'tempfile'
require 'find'
require_relative 'dryrun_utils'
require_relative 'manifest_parser'
require_relative 'gradle_adapter'
module Dryrun
class AndroidProject
def initialize(path, custom_app_path, custom_module, flavour, device)
@custom_app_path = custom_app_pa... | ruby | MIT | 3cdd6e89b25b10bcc97394a2537bf4725a98780a | 2026-01-04T15:48:46.137022Z | false |
cesarferreira/dryrun | https://github.com/cesarferreira/dryrun/blob/3cdd6e89b25b10bcc97394a2537bf4725a98780a/lib/dryrun/device.rb | lib/dryrun/device.rb | module Dryrun
class Device
attr_accessor :name, :id
def initialize(name, id)
@name = name
@id = id
end
end
end
| ruby | MIT | 3cdd6e89b25b10bcc97394a2537bf4725a98780a | 2026-01-04T15:48:46.137022Z | false |
cesarferreira/dryrun | https://github.com/cesarferreira/dryrun/blob/3cdd6e89b25b10bcc97394a2537bf4725a98780a/lib/dryrun/android_utils.rb | lib/dryrun/android_utils.rb | require_relative 'dryrun_utils'
module Dryrun
class AndroidUtils
def self.pretty_run(execute_line, package)
puts "Installing #{package.green}...\n"
puts "executing: #{execute_line.green}\n"
DryrunUtils.run_adb("shell #{execute_line}")
end
def self.clear_app_data(package)
Dryrun... | ruby | MIT | 3cdd6e89b25b10bcc97394a2537bf4725a98780a | 2026-01-04T15:48:46.137022Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/app/controllers/clearance/passwords_controller.rb | app/controllers/clearance/passwords_controller.rb | require "active_support/deprecation"
class Clearance::PasswordsController < Clearance::BaseController
before_action :ensure_existing_user, only: [:edit, :update]
before_action :ensure_email_present, only: [:create]
skip_before_action :require_login, only: [:create, :edit, :new, :update], raise: false
def new
... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/app/controllers/clearance/users_controller.rb | app/controllers/clearance/users_controller.rb | class Clearance::UsersController < Clearance::BaseController
before_action :redirect_signed_in_users, only: [:create, :new]
skip_before_action :require_login, only: [:create, :new], raise: false
def new
@user = user_from_params
render template: "users/new"
end
def create
@user = user_from_params... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/app/controllers/clearance/base_controller.rb | app/controllers/clearance/base_controller.rb | module Clearance
# Top-level base class that all Clearance controllers inherit from.
# Inherits from `ApplicationController` by default and can be overridden by
# setting a new value with {Configuration#parent_controller=}.
# @!parse
# class BaseController < ApplicationController; end
class BaseController... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/app/controllers/clearance/sessions_controller.rb | app/controllers/clearance/sessions_controller.rb | class Clearance::SessionsController < Clearance::BaseController
before_action :redirect_signed_in_users, only: [:new]
skip_before_action :require_login, only: [:create, :new, :destroy], raise: false
def create
@user = authenticate(params)
sign_in(@user) do |status|
if status.success?
redir... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/app/mailers/clearance_mailer.rb | app/mailers/clearance_mailer.rb | class ClearanceMailer < ActionMailer::Base
def change_password(user)
@user = user
mail(
from: Clearance.configuration.mailer_sender,
to: @user.email,
subject: I18n.t(
:change_password,
scope: [:clearance, :models, :clearance_mailer]
)
)
end
end
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/configuration_spec.rb | spec/configuration_spec.rb | require "spec_helper"
MyController = Class.new
DummyGuard = Class.new
Account = Class.new(ActiveRecord::Base)
CustomUser = Class.new(ActiveRecord::Base)
ConfiguredUser = Class.new
MyUser = Class.new
describe Clearance::Configuration do
let(:config) { Clearance.configuration }
context "when no user_model_name is ... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/spec_helper.rb | spec/spec_helper.rb | ENV["RAILS_ENV"] ||= "test"
require_relative "dummy/config/environment"
require "rspec/rails"
require "clearance/rspec"
Dir[File.expand_path("spec/support/**/*.rb")].each { |f| require f }
RSpec.configure do |config|
config.include ActiveSupport::Testing::TimeHelpers
config.include FactoryBot::Syntax::Methods
... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/support/clearance.rb | spec/support/clearance.rb | require "clearance"
Clearance.configure do |config|
# need an empty block to initialize the configuration object
end
# NOTE: to run the entire suite with signed cookies
# you can set the signed_cookie default to true
# and run all specs.
# However, to fake the actual signing process you
# ca... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/support/request_with_remember_token.rb | spec/support/request_with_remember_token.rb | module RememberTokenHelpers
def request_with_remember_token(remember_token)
cookies = ActionDispatch::Request.new({}).cookie_jar
if Clearance.configuration.signed_cookie
cookies.signed[Clearance.configuration.cookie_name] = remember_token
else
cookies[Clearance.configuration.cookie_name] = rem... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/support/fake_model_without_password_strategy.rb | spec/support/fake_model_without_password_strategy.rb | module FakeModelWithoutPasswordStrategy
def fake_model_without_password_strategy
Class.new do
include ActiveModel::Validations
validates_with UniquenessValidator
def self.before_validation(*)
end
def self.before_create(*)
end
include Clearance::User
end.new
end
... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/support/fake_model_with_password_strategy.rb | spec/support/fake_model_with_password_strategy.rb | module FakeModelWithPasswordStrategy
def fake_model_with_password_strategy(password_strategy)
Class.new do
attr_reader :password
attr_accessor :encrypted_password, :salt
include password_strategy
end.new
end
end
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/support/generator_spec_helpers.rb | spec/support/generator_spec_helpers.rb | require "ammeter/rspec/generator/example"
require "ammeter/rspec/generator/matchers"
require "ammeter/init"
module GeneratorSpecHelpers
module FileMethods
def file(path)
Pathname.new(super)
end
def migration_file(path)
Pathname.new(super)
end
end
TEMPLATE_PATH = File.expand_path("..... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/routing/clearance_routes_spec.rb | spec/routing/clearance_routes_spec.rb | require "spec_helper"
describe "routes for Clearance" do
context "routes enabled" do
it "draws the default routes" do
expect(get: "sign_up").to be_routable
expect(get: "sign_in").to be_routable
expect(get: "passwords/new").to be_routable
expect(post: "session").to be_routable
expect... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/requests/csrf_rotation_spec.rb | spec/requests/csrf_rotation_spec.rb | require "spec_helper"
describe "CSRF Rotation" do
around do |example|
ActionController::Base.allow_forgery_protection = true
example.run
ActionController::Base.allow_forgery_protection = false
end
context "Clearance is configured to rotate CSRF token on sign in" do
describe "sign in" do
it... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/requests/authentication_cookie_spec.rb | spec/requests/authentication_cookie_spec.rb | require "spec_helper"
class PagesController < ApplicationController
include Clearance::Controller
before_action :require_login, only: :private
# A page requiring user authentication
def private
head :ok
end
# A page that does not require user authentication
def public
head :ok
end
end
descr... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/requests/password_maintenance_spec.rb | spec/requests/password_maintenance_spec.rb | require "spec_helper"
describe "Password maintenance" do
context "when updating the password" do
it "signs the user in and redirects" do
user = create(:user, :with_forgotten_password)
put user_password_url(user), params: {
user_id: user,
token: user.confirmation_token,
passwo... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/requests/backdoor_spec.rb | spec/requests/backdoor_spec.rb | require "spec_helper"
describe "Backdoor Middleware" do
it "allows signing in using query parameter" do
user = create(:user)
get root_path(as: user.to_param)
expect(cookies["remember_token"]).to eq user.remember_token
end
it "removes the `as` param but leaves other parameters unchanged" do
use... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/requests/token_expiration_spec.rb | spec/requests/token_expiration_spec.rb | require "spec_helper"
describe "Token expiration" do
describe "after signing in" do
before do
freeze_time
create_user_and_sign_in
@initial_cookies = remember_token_cookies
end
after do
unfreeze_time
end
it "should have a remember_token cookie with a future expiration" do... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/requests/cookie_options_spec.rb | spec/requests/cookie_options_spec.rb | require "spec_helper"
describe "Cookie options" do
before do
Clearance.configuration.httponly = httponly
end
context "when httponly config value is false" do
let(:httponly) { false }
describe "sign in" do
before do
user = create(:user, password: "password")
get sign_in_path
... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/helpers/helper_helpers_spec.rb | spec/helpers/helper_helpers_spec.rb | require "spec_helper"
describe "Clearance RSpec helper spec configuration", type: :helper do
it "lets me use clearance's helper methods in helper specs" do
user = double("User")
sign_in_as(user)
expect(helper.current_user).to eq user
end
end
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/factories/users.rb | spec/factories/users.rb | FactoryBot.define do
sequence :email do |n|
"user#{n}@example.com"
end
factory :user do
email
password { "password" }
trait :with_forgotten_password do
confirmation_token { Clearance::Token.new }
end
factory :user_with_optional_password, class: "UserWithOptionalPassword" do
... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/controllers/forgeries_controller_spec.rb | spec/controllers/forgeries_controller_spec.rb | require "spec_helper"
class ForgeriesController < ActionController::Base
include Clearance::Controller
protect_from_forgery
before_action :require_login
# This is off in test by default, but we need it for this test
self.allow_forgery_protection = true
def create
redirect_to action: "index"
end
e... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/controllers/permissions_controller_spec.rb | spec/controllers/permissions_controller_spec.rb | require "spec_helper"
class PermissionsController < ActionController::Base
include Clearance::Controller
before_action :require_login, only: :show
def new
head :ok
end
def show
head :ok
end
end
describe PermissionsController do
before do
Rails.application.routes.draw do
resource :pe... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/controllers/apis_controller_spec.rb | spec/controllers/apis_controller_spec.rb | require "spec_helper"
class ApisController < ActionController::Base
include Clearance::Controller
before_action :require_login
def show
head :ok
end
end
describe ApisController do
before do
Rails.application.routes.draw do
resource :api, only: [:show]
end
end
after do
Rails.appl... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/controllers/sessions_controller_spec.rb | spec/controllers/sessions_controller_spec.rb | require "spec_helper"
describe Clearance::SessionsController do
it { should be_a Clearance::BaseController }
describe "on GET to #new" do
context "when a user is not signed in" do
before { get :new }
it { should respond_with(:success) }
it { should render_template(:new) }
it { should_... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/controllers/users_controller_spec.rb | spec/controllers/users_controller_spec.rb | require "spec_helper"
describe Clearance::UsersController do
it { should be_a Clearance::BaseController }
describe "on GET to #new" do
context "when signed out" do
it "renders a form for a new user" do
get :new
expect(response).to be_successful
expect(response).to render_templat... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/controllers/passwords_controller_spec.rb | spec/controllers/passwords_controller_spec.rb | require "spec_helper"
describe Clearance::PasswordsController do
it { is_expected.to be_a Clearance::BaseController }
describe "#new" do
it "renders the password reset form" do
get :new
expect(response).to be_successful
expect(response).to render_template(:new)
end
end
describe "#c... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/app_templates/app/controllers/application_controller.rb | spec/app_templates/app/controllers/application_controller.rb | class ApplicationController < ActionController::Base
end
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/app_templates/app/models/user.rb | spec/app_templates/app/models/user.rb | class User < ApplicationRecord
def previously_existed?
true
end
end
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/app_templates/testapp/app/controllers/home_controller.rb | spec/app_templates/testapp/app/controllers/home_controller.rb | class HomeController < ApplicationController
def show
render html: "", layout: "application"
end
end
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/app_templates/testapp/config/routes.rb | spec/app_templates/testapp/config/routes.rb | Rails.application.routes.draw do
root to: "home#show"
end
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/app_templates/testapp/config/initializers/action_mailer.rb | spec/app_templates/testapp/config/initializers/action_mailer.rb | ActionMailer::Base.default_url_options[:host] = "localhost"
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/app_templates/config/routes.rb | spec/app_templates/config/routes.rb | Rails.application.routes.draw do
root to: "application#show"
end
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/app_templates/config/initializers/clearance.rb | spec/app_templates/config/initializers/clearance.rb | Clearance.configure do |config|
end
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/models/user_spec.rb | spec/models/user_spec.rb | require "spec_helper"
describe User do
it { is_expected.to have_db_index(:email) }
it { is_expected.to have_db_index(:remember_token) }
it { is_expected.to validate_presence_of(:email) }
it { is_expected.to validate_presence_of(:password) }
it { is_expected.to allow_value("foo@example.co.uk").for(:email) }
... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/acceptance/clearance_installation_spec.rb | spec/acceptance/clearance_installation_spec.rb | require "spec_helper"
describe "Clearance Installation" do
around do |example|
Dir.chdir("tmp") do
FileUtils.rm_rf("testapp")
example.run
end
end
it "can successfully run specs" do
app_name = "testapp"
generate_test_app(app_name)
Dir.chdir(app_name) do
configure_test_app
... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/generators/clearance/routes/routes_generator_spec.rb | spec/generators/clearance/routes/routes_generator_spec.rb | require "spec_helper"
require "generators/clearance/routes/routes_generator"
describe Clearance::Generators::RoutesGenerator, :generator do
it "adds clearance routes to host application routes" do
provide_existing_routes_file
provide_existing_initializer
routes = file("config/routes.rb")
initializer... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/generators/clearance/views/views_generator_spec.rb | spec/generators/clearance/views/views_generator_spec.rb | require "spec_helper"
require "generators/clearance/views/views_generator"
describe Clearance::Generators::ViewsGenerator, :generator do
it "copies clearance views to the host application" do
run_generator
views = %w[
clearance_mailer/change_password.html.erb
clearance_mailer/change_password.tex... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/generators/clearance/specs/specs_generator_spec.rb | spec/generators/clearance/specs/specs_generator_spec.rb | require "spec_helper"
require "generators/clearance/specs/specs_generator"
describe Clearance::Generators::SpecsGenerator, :generator do
it "copies specs to host app" do
run_generator
specs = %w[
factories/clearance
features/clearance/user_signs_out_spec
features/clearance/visitor_resets_p... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/generators/clearance/install/install_generator_spec.rb | spec/generators/clearance/install/install_generator_spec.rb | require "spec_helper"
require "generators/clearance/install/install_generator"
describe Clearance::Generators::InstallGenerator, :generator do
describe "initializer" do
it "is copied to the application" do
provide_existing_application_controller
run_generator
initializer = file("config/initial... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/views/view_helpers_spec.rb | spec/views/view_helpers_spec.rb | require "spec_helper"
describe "Clearance RSpec view spec configuration", type: :view do
it "lets me use clearance's helper methods in view specs" do
user = double("User")
sign_in_as(user)
expect(view.current_user).to eq user
end
end
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/password_strategies/password_strategies_spec.rb | spec/password_strategies/password_strategies_spec.rb | require "spec_helper"
describe "Password strategy configuration" do
include FakeModelWithoutPasswordStrategy
describe "when Clearance.configuration.password_strategy is set" do
it "includes the value it is set to" do
mock_password_strategy = Module.new
Clearance.configuration.password_strategy = ... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/password_strategies/argon2_spec.rb | spec/password_strategies/argon2_spec.rb | require "spec_helper"
describe Clearance::PasswordStrategies::Argon2 do
include FakeModelWithPasswordStrategy
describe "#password=" do
it "encrypts the password into encrypted_password" do
stub_argon2_password
model_instance = fake_model_with_argon2_strategy
model_instance.password = passwo... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/password_strategies/bcrypt_spec.rb | spec/password_strategies/bcrypt_spec.rb | require "spec_helper"
describe Clearance::PasswordStrategies::BCrypt do
include FakeModelWithPasswordStrategy
describe "#password=" do
it "encrypts the password into encrypted_password" do
stub_bcrypt_password
model_instance = fake_model_with_bcrypt_strategy
model_instance.password = passwo... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/dummy/app/controllers/application_controller.rb | spec/dummy/app/controllers/application_controller.rb | class ApplicationController < ActionController::Base
include Clearance::Controller
def show
render inline: "Hello user #<%= current_user.id %> #{params.to_json}", layout: false
end
end
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/dummy/app/models/user_with_optional_password.rb | spec/dummy/app/models/user_with_optional_password.rb | class UserWithOptionalPassword < User
private
def password_optional?
true
end
end
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/dummy/app/models/user.rb | spec/dummy/app/models/user.rb | class User < ActiveRecord::Base
include Clearance::User
end
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/dummy/db/schema.rb | spec/dummy/db/schema.rb | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rai... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/dummy/db/migrate/20110111224543_create_clearance_users.rb | spec/dummy/db/migrate/20110111224543_create_clearance_users.rb | class CreateClearanceUsers < ActiveRecord::Migration[Rails::VERSION::STRING.to_f]
def self.up
create_table :users do |t|
t.timestamps null: false
t.string :email, null: false
t.string :encrypted_password, limit: 128, null: false
t.string :confirmation_token, limit: 128
t.string :reme... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/dummy/config/application.rb | spec/dummy/config/application.rb | require_relative "boot"
require "rails/all"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Dummy
class Application < Rails::Application
config.load_defaults Rails::VERSION::STRING.to_f
end
end
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/dummy/config/environment.rb | spec/dummy/config/environment.rb | # Load the Rails application.
require_relative "application"
# Initialize the Rails application.
Rails.application.initialize!
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/dummy/config/routes.rb | spec/dummy/config/routes.rb | Rails.application.routes.draw do
root to: "application#show"
end
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/dummy/config/boot.rb | spec/dummy/config/boot.rb | # Set up gems listed in the Gemfile.
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
$LOAD_PATH.unshift File.expand_path("../../../lib", __dir__)
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/dummy/config/environments/test.rb | spec/dummy/config/environments/test.rb | require "active_support/core_ext/integer/time"
Rails.application.configure do
config.enable_reloading = false
config.eager_load = ENV["CI"].present?
config.public_file_server.headers = {"Cache-Control" => "public, max-age=#{1.hour.to_i}"}
# Show full error reports and disable caching.
config.consider_all_... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/clearance/rack_session_spec.rb | spec/clearance/rack_session_spec.rb | require "spec_helper"
describe Clearance::RackSession do
it "injects a clearance session into the environment" do
headers = {"X-Roaring-Lobster" => "Red"}
app = Rack::Builder.new do
use Clearance::RackSession
run lambda { |env| Rack::Response.new(env[:clearance], 200, headers).finish }
end
... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/clearance/token_spec.rb | spec/clearance/token_spec.rb | require "spec_helper"
describe Clearance::Token do
it "is a random hex string" do
token = "my_token"
allow(SecureRandom).to receive(:hex).with(20).and_return(token)
expect(Clearance::Token.new).to eq token
end
end
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/clearance/default_sign_in_guard_spec.rb | spec/clearance/default_sign_in_guard_spec.rb | require "spec_helper"
describe Clearance::DefaultSignInGuard do
context "session is signed in" do
it "returns success" do
session = double("Session", signed_in?: true)
guard = Clearance::DefaultSignInGuard.new(session)
expect(guard.call).to be_a Clearance::SuccessStatus
end
end
contex... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/clearance/sign_in_guard_spec.rb | spec/clearance/sign_in_guard_spec.rb | require "spec_helper"
module Clearance
describe SignInGuard do
it "handles success" do
sign_in_guard = SignInGuard.new(double("session"))
status = double("status")
allow(SuccessStatus).to receive(:new).and_return(status)
expect(sign_in_guard.success).to eq(status)
end
it "handle... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/clearance/session_spec.rb | spec/clearance/session_spec.rb | require "spec_helper"
describe Clearance::Session do
before { freeze_time }
after { unfreeze_time }
let(:session) { Clearance::Session.new(env_without_remember_token) }
let(:user) { create(:user) }
it "finds a user from a cookie" do
user = create(:user)
env = env_with_remember_token(user.remember_t... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/clearance/controller_spec.rb | spec/clearance/controller_spec.rb | require "spec_helper"
describe Clearance::Controller, type: :controller do
controller(ActionController::Base) do
include Clearance::Controller
end
it "exposes no action methods" do
expect(controller.action_methods).to be_empty
end
end
| ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/clearance/back_door_spec.rb | spec/clearance/back_door_spec.rb | require "spec_helper"
describe Clearance::BackDoor do
it "signs in as a given user" do
user_id = "123"
user = double("user")
allow(User).to receive(:find).with(user_id).and_return(user)
env = env_for_user_id(user_id)
back_door = Clearance::BackDoor.new(mock_app)
result = back_door.call(env)
... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/clearance/constraints/signed_out_spec.rb | spec/clearance/constraints/signed_out_spec.rb | require "spec_helper"
describe Clearance::Constraints::SignedOut do
it "returns true when user is signed out" do
constraint = Clearance::Constraints::SignedOut.new
request = request_without_remember_token
expect(constraint.matches?(request)).to eq true
end
it "returns false when user is not signed o... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/clearance/constraints/signed_in_spec.rb | spec/clearance/constraints/signed_in_spec.rb | require "spec_helper"
describe Clearance::Constraints::SignedIn do
it "returns true when user is signed in" do
user = create(:user)
constraint = Clearance::Constraints::SignedIn.new
request = request_with_remember_token(user.remember_token)
expect(constraint.matches?(request)).to eq true
end
it ... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/clearance/testing/view_helpers_spec.rb | spec/clearance/testing/view_helpers_spec.rb | require "spec_helper"
describe Clearance::Testing::ViewHelpers do
describe "#sign_in" do
it "sets the signed in user to a new user object" do
user_model = Class.new
allow(Clearance.configuration).to receive(:user_model)
.and_return(user_model)
view = test_view_class.new
view.sign... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/clearance/testing/controller_helpers_spec.rb | spec/clearance/testing/controller_helpers_spec.rb | require "spec_helper"
class TestClass
include Clearance::Testing::ControllerHelpers
def initialize
@request = Class.new do
def env
{clearance: Clearance::Session.new({})}
end
end.new
end
end
MyUserModel = Class.new
describe Clearance::Testing::ControllerHelpers do
describe "#sign... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/clearance/testing/deny_access_matcher_spec.rb | spec/clearance/testing/deny_access_matcher_spec.rb | require "spec_helper"
class PretendFriendsController < ActionController::Base
include Clearance::Controller
before_action :require_login
def index
end
end
describe PretendFriendsController, type: :controller do
before do
Rails.application.routes.draw do
resources :pretend_friends, only: :index
... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
thoughtbot/clearance | https://github.com/thoughtbot/clearance/blob/14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a/spec/mailers/clearance_mailer_spec.rb | spec/mailers/clearance_mailer_spec.rb | require "spec_helper"
Person = Class.new(User)
describe ClearanceMailer do
it "is from DO_NOT_REPLY" do
user = create(:user)
user.forgot_password!
email = ClearanceMailer.change_password(user)
expect(Clearance.configuration.mailer_sender).to eq(email.from[0])
end
it "is sent to user" do
u... | ruby | MIT | 14e9ba3d8f8bc865e389c743df4f9e8b2c7b3d9a | 2026-01-04T15:48:57.317428Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.