source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/response_spec.rb
Ruby
mit
302
master
5,487
# frozen_string_literal: true require 'spec_helper' describe Praxis::Response do let(:spec_status) { 200 } let(:spec_location) { /resources/ } let(:spec_headers) { { 'X-Header' => 'Foobar' } } let(:spec_mime_type) { 'application/vnd.resource' } let(:application_vnd_resource_media_type) do Cla...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/routing_config_spec.rb
Ruby
mit
302
master
2,439
# frozen_string_literal: true require 'spec_helper' describe Praxis::RoutingConfig do let(:endpoint_definition) do Class.new do include Praxis::EndpointDefinition def self.name 'MyResource' end end end let(:routing_block) { proc {} } let(:base_path) { '' } let(:default_rou...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/responses/internal_server_error_spec.rb
Ruby
mit
302
master
2,285
# frozen_string_literal: true require 'spec_helper' describe Praxis::Responses::InternalServerError do context 'a basic response' do subject(:response) { Praxis::Responses::InternalServerError.new } it 'always sets the json content type' do expect(response.name).to be(:internal_server_error) exp...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/responses/validation_error_spec.rb
Ruby
mit
302
master
2,862
# frozen_string_literal: true require 'spec_helper' describe Praxis::Responses::ValidationError do let(:summary) { 'Something happened here' } context 'a basic response' do subject(:response) { Praxis::Responses::ValidationError.new(summary: summary) } it 'always sets the json content type' do expec...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/mapper/resource_spec.rb
Ruby
mit
302
master
12,454
# frozen_string_literal: true require 'spec_helper' describe Praxis::Mapper::Resource do let(:parent_record) { ParentModel.new(id: 100, name: 'george sr') } let(:parent_records) { [ParentModel.new(id: 101, name: 'georgia'), ParentModel.new(id: 102, name: 'georgina')] } let(:other_model) { OtherModel.new(name: '...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/mapper/selector_generator_spec.rb
Ruby
mit
302
master
34,822
# frozen_string_literal: true require 'spec_helper' describe Praxis::Mapper::SelectorGenerator do let(:resource) { SimpleResource } subject(:generator) { described_class.new } context '#add' do let(:resource) { SimpleResource } shared_examples 'a proper selector' do it do dumped = generat...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/mapper/resources/typed_methods_spec.rb
Ruby
mit
302
master
7,817
# frozen_string_literal: true require 'spec_helper' describe Praxis::Mapper::Resources::TypedMethods do let(:resource_class) { TypedResource } context '._finalize!' do # The class is already finalized by loading the TypedResource from the spec_resources # So we will simply check that all the right things...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/mapper/resources/callbacks_spec.rb
Ruby
mit
302
master
1,831
# frozen_string_literal: true require 'spec_helper' describe Praxis::Mapper::Resources::Callbacks do context 'callbacks' do let(:double_model) do SimpleModel.new(before_count: 0, after_count: 0, around_count: 0, name: '', force: false) end let(:resource) { SimpleResource.new(double_model) } co...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/mapper/resources/query_proxy_spec.rb
Ruby
mit
302
master
4,289
# frozen_string_literal: true require 'spec_helper' describe Praxis::Mapper::Resources::QueryProxy do let(:instance) { described_class.new(klass: resource_class) } let(:resource_class) { SimpleResource } let(:the_includes) { nil } context 'including' do let(:the_includes) { %i[one two] } it 'saves th...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/extensions/field_expansion_spec.rb
Ruby
mit
302
master
2,015
# frozen_string_literal: true require 'spec_helper' require 'praxis/extensions/field_selection' describe Praxis::Extensions::FieldExpansion do # include the ActionDefinitionExtension module directly, as that's where the # bulk of lies, and by including this instead of the base FieldExpansion module # we avoid ...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/extensions/rendering_spec.rb
Ruby
mit
302
master
1,986
# frozen_string_literal: true require 'spec_helper' describe Praxis::Extensions::Rendering do let(:test_class) do Struct.new(:media_type, :expanded_fields, :response, :request) do |_klass| include Praxis::Extensions::Rendering end end let(:media_type) { Person } let(:expanded_fields) { { id: tr...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/extensions/field_selection/sequel_query_selector_spec.rb
Ruby
mit
302
master
5,426
# frozen_string_literal: true require 'spec_helper' require 'sequel' require 'praxis/extensions/field_selection/sequel_query_selector' class QTest attr_reader :object, :cols def initialize @object = {} @cols = [] end def eager(hash) raise 'we are only calling eager one at a time!' if hash.keys....
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/extensions/field_selection/active_record_query_selector_spec.rb
Ruby
mit
302
master
5,052
# frozen_string_literal: true require 'spec_helper' describe Praxis::Extensions::FieldSelection::ActiveRecordQuerySelector do let(:selector_fields) do { name: true, author: { id: true, books: true, }, category: { name: true, books: true, }, tag...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/extensions/field_selection/field_selector_spec.rb
Ruby
mit
302
master
2,634
# frozen_string_literal: true require 'spec_helper' require 'praxis/extensions/field_selection' describe Praxis::Extensions::FieldSelection::FieldSelector do let(:type) { described_class.for(Address) } subject(:field_selector) { type.load(fields) } context '.example' do subject(:example) { type.example }...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/extensions/attribute_filtering/filters_parser_spec.rb
Ruby
mit
302
master
6,170
# frozen_string_literal: true require 'praxis/extensions/attribute_filtering/filters_parser' describe Praxis::Extensions::AttributeFiltering::FilteringParams::Condition do end describe Praxis::Extensions::AttributeFiltering::FilteringParams::ConditionGroup do end describe Praxis::Extensions::AttributeFiltering::Fil...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/extensions/attribute_filtering/filtering_params_spec.rb
Ruby
mit
302
master
14,002
# frozen_string_literal: true require 'spec_helper' require 'praxis/extensions/attribute_filtering' describe Praxis::Extensions::AttributeFiltering::FilteringParams do context '.load' do subject { described_class.load(filters_string) } context 'unescapes the URL encoded values' do it 'for single val...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/extensions/attribute_filtering/filter_tree_node_spec.rb
Ruby
mit
302
master
3,742
# frozen_string_literal: true require 'spec_helper' require 'praxis/extensions/attribute_filtering' describe Praxis::Extensions::AttributeFiltering::FilterTreeNode do let(:dummy_object) { double('Fake NodeObject') } let(:filters) do [ { name: 'one', op: '>', value: 1, node_object: dummy_object }, ...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/extensions/attribute_filtering/active_record_filter_query_builder_spec.rb
Ruby
mit
302
master
27,931
# frozen_string_literal: true require 'spec_helper' require 'praxis/extensions/attribute_filtering' require 'praxis/extensions/attribute_filtering/active_record_filter_query_builder' describe Praxis::Extensions::AttributeFiltering::ActiveRecordFilterQueryBuilder do let(:root_resource) { ActiveBookResource } let(...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/extensions/pagination/ordering_params_spec.rb
Ruby
mit
302
master
2,509
# frozen_string_literal: true require 'spec_helper' require_relative '../../../support/spec_media_types' describe Praxis::Extensions::Pagination::OrderingParams do let(:blog_ordering_type) { Praxis::Types::OrderingParams.for(Blog) } context '#validate' do context 'full enforcement and nested relationships' d...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/extensions/pagination/active_record_pagination_handler_spec.rb
Ruby
mit
302
master
9,505
# frozen_string_literal: true require 'spec_helper' require 'praxis/extensions/pagination' describe Praxis::Extensions::Pagination::ActiveRecordPaginationHandler do let(:book_pagination_params_attribute) do Attributor::Attribute.new(Praxis::Types::PaginationParams.for(Book)) do max_items 3 page_siz...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/handlers/json_spec.rb
Ruby
mit
302
master
946
# frozen_string_literal: true require 'spec_helper' describe Praxis::Handlers::JSON do let(:dictionary) { { 'foo' => 1 } } let(:dictionary_json) { '{"foo":1}' } let(:array) { [1, 2, 3] } let(:array_json) { '[1,2,3]' } describe '#parse' do it 'handles dictionaries' do expect(subject.parse(diction...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/types/fuzzy_hash_spec.rb
Ruby
mit
302
master
446
# frozen_string_literal: true require 'spec_helper' describe Praxis::Types::FuzzyHash do let(:initial_value) do { 'key' => 'value', /bob/ => 'rob', /\d+/ => 'one' } end subject(:hash) { Praxis::Types::FuzzyHash.new(initial_value) } its(['key']) { should eq 'value' } its([/bob/]) ...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/types/multipart_array_spec.rb
Ruby
mit
302
master
11,896
# frozen_string_literal: true require 'spec_helper' describe Praxis::Types::MultipartArray do let(:type) do Class.new(Praxis::Types::MultipartArray) do options[:case_insensitive_load] = true part 'title', String, required: true part(/nam/, String, regexp: /Bob/i) part(/stuff/) do ...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/multipart/parser_spec.rb
Ruby
mit
302
master
1,561
# frozen_string_literal: true require 'spec_helper' describe Praxis::MultipartParser do let(:form) do form_data = MIME::Multipart::FormData.new destination_path = MIME::Text.new('/etc/defaults') form_data.add destination_path, 'destination_path' form_data end let(:headers) { form.headers.head...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/request_stages/action_spec.rb
Ruby
mit
302
master
2,471
# frozen_string_literal: true require 'spec_helper' describe Praxis::RequestStages::Action do let(:controller) do Class.new do include Praxis::Controller end.new(request) end let(:action) { double('action', name: 'foo') } let(:response) { Praxis::Responses::Ok.new } let(:app) { double('App', ...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/request_stages/validate_spec.rb
Ruby
mit
302
master
1,229
# frozen_string_literal: true require 'spec_helper' describe Praxis::RequestStages::Validate do let(:dispatcher) { Praxis::Dispatcher.new } # Instances controller is defined in the 'app' folder and is already in scope. Using this # controller for the specs instead of creating a simple controller. let(:contro...
github
praxis/praxis
https://github.com/praxis/praxis
spec/praxis/request_stages/request_stage_spec.rb
Ruby
mit
302
master
5,437
# frozen_string_literal: true require 'spec_helper' describe Praxis::RequestStages::RequestStage do let(:controller_class) do Class.new do include Praxis::Controller end end let(:stage_class) { Class.new(Praxis::RequestStages::RequestStage) } let(:request) { Praxis::Request.new({}) } let(:co...
github
amatsuda/html5_validators
https://github.com/amatsuda/html5_validators
Gemfile
Ruby
mit
302
master
1,446
# frozen_string_literal: true source 'https://rubygems.org' # Specify your gem's dependencies in html5_validators.gemspec gemspec if ENV['RAILS_VERSION'] == 'edge' gem 'railties', git: 'https://github.com/rails/rails.git' gem 'activerecord', git: 'https://github.com/rails/rails.git' gem 'sqlite3' elsif ENV['RAI...
github
amatsuda/html5_validators
https://github.com/amatsuda/html5_validators
html5_validators.gemspec
Ruby
mit
302
master
1,233
# -*- encoding: utf-8 -*- # frozen_string_literal: true $:.push File.expand_path('../lib', __FILE__) require 'html5_validators/version' Gem::Specification.new do |s| s.name = 'html5_validators' s.version = Html5Validators::VERSION s.platform = Gem::Platform::RUBY s.authors = ['Akira Matsuda']...
github
amatsuda/html5_validators
https://github.com/amatsuda/html5_validators
Rakefile
Ruby
mit
302
master
401
# frozen_string_literal: true require 'bundler/gem_tasks' require 'rake/testtask' Rake::TestTask.new do |t| t.libs << 'test' if Gem.loaded_specs['activerecord'] t.test_files = Dir['test/**/*_test.rb'] else t.test_files = Dir['test/**/*_test.rb'] - Dir['test/**/*active_record*'] - Dir['test/**/*active_rec...
github
amatsuda/html5_validators
https://github.com/amatsuda/html5_validators
lib/html5_validators.rb
Ruby
mit
302
master
776
# frozen_string_literal: true require 'rails' module Html5Validators @enabled = true class << self attr_accessor :enabled end class Railtie < ::Rails::Railtie #:nodoc: initializer 'html5_validators' do config.after_initialize do require 'html5_validators/active_model/helper_methods' ...
github
amatsuda/html5_validators
https://github.com/amatsuda/html5_validators
lib/html5_validators/active_model/helper_methods.rb
Ruby
mit
302
master
2,796
# frozen_string_literal: true module Html5Validators module DafaultValidationContext if defined?(::ActiveRecord::Base) && (::ActiveRecord::VERSION::MAJOR < 5) refine ::ActiveRecord::Base do def default_validation_context new_record? ? :create : :update end end end re...
github
amatsuda/html5_validators
https://github.com/amatsuda/html5_validators
lib/html5_validators/active_model/validations.rb
Ruby
mit
302
master
443
# frozen_string_literal: true module Html5Validators module ActiveModelExtension extend ActiveSupport::Concern included do cattr_accessor :auto_html5_validation, instance_accessor: false, instance_reader: false, instance_writer: false end end end module ActiveModel module Validations attr...
github
amatsuda/html5_validators
https://github.com/amatsuda/html5_validators
lib/html5_validators/action_view/form_helpers_rails3.rb
Ruby
mit
302
master
3,360
# frozen_string_literal: true # Legacy Rails 3.x support module ActionView module Helpers module FormHelper def form_for_with_auto_html5_validation_option(record, options = {}, &proc) if record.respond_to?(:auto_html5_validation=) if !Html5Validators.enabled || (options[:auto_html5_valida...
github
amatsuda/html5_validators
https://github.com/amatsuda/html5_validators
lib/html5_validators/action_view/form_helpers.rb
Ruby
mit
302
master
2,998
# frozen_string_literal: true module Html5Validators module ActionViewExtension module FormHelper def form_for(record, options = {}, &block) if record.respond_to?(:auto_html5_validation=) if !Html5Validators.enabled || (options[:auto_html5_validation] == false) record.auto_htm...
github
amatsuda/html5_validators
https://github.com/amatsuda/html5_validators
lib/html5_validators/active_record/base.rb
Ruby
mit
302
master
716
# frozen_string_literal: true module Html5Validators module ActiveRecordExtension extend ActiveSupport::Concern # Future subclasses will pick up the model extension module ClassMethods def inherited(kls) super class << kls attr_accessor :auto_html5_validation end ...
github
amatsuda/html5_validators
https://github.com/amatsuda/html5_validators
test/fake_app.rb
Ruby
mit
302
master
5,747
# frozen_string_literal: true require 'action_controller/railtie' require 'active_model' begin require 'active_record' rescue LoadError end # config class Html5ValidatorsTestApp < Rails::Application config.secret_token = "You know I'm born to lose, and gambling's for fools, But that's the way I like it baby, I do...
github
amatsuda/html5_validators
https://github.com/amatsuda/html5_validators
test/test_helper.rb
Ruby
mit
302
master
1,750
# frozen_string_literal: true ENV['RAILS_ENV'] ||= 'test' $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.dirname(__FILE__)) # require logger before rails, or Rails 6 fails to boot require 'logger' # load Rails first require 'rails' require 'bundler/setup' Bundler.require b...
github
amatsuda/html5_validators
https://github.com/amatsuda/html5_validators
test/features/active_record_validation_test.rb
Ruby
mit
302
master
5,466
# frozen_string_literal: true require 'test_helper' class ActiveRecordValidationTest < ActionDispatch::IntegrationTest FORM_ID_LIST = if Rails::VERSION::STRING >= '5.1' %w[#form_for #form_with].freeze else %w[#form_for].freeze end teardown d...
github
amatsuda/html5_validators
https://github.com/amatsuda/html5_validators
test/features/active_model_validation_test.rb
Ruby
mit
302
master
3,750
# frozen_string_literal: true require 'test_helper' class ActiveModelValidationTest < ActionDispatch::IntegrationTest FORM_ID_LIST = if Rails::VERSION::STRING >= '5.1' %w[#form_for #form_with].freeze else %w[#form_for].freeze end teardown do...
github
amatsuda/html5_validators
https://github.com/amatsuda/html5_validators
test/models/active_record/inherited_test.rb
Ruby
mit
302
master
581
# frozen_string_literal: true require 'test_helper' if defined? ActiveRecord class Html5Validators::ActiveRecordExtensionTest < ActiveSupport::TestCase test 'An AR model' do assert_respond_to Class.new(ActiveRecord::Base), :auto_html5_validation end test "Changing a model's auto_html5_validation ...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
Rakefile
Ruby
mit
302
main
216
# frozen_string_literal: true require 'bundler/gem_tasks' require 'rspec/core/rake_task' require 'rubocop/rake_task' RSpec::Core::RakeTask.new(:spec) RuboCop::RakeTask.new(:rubocop) task default: %i[spec rubocop]
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
Appraisals
Ruby
mit
302
main
844
# frozen_string_literal: true appraise 'activejob-4.2.x' do gem 'activejob', '~> 4.2.11' end appraise 'activejob-5.2.x' do gem 'activejob', '~> 5.2.8' end appraise 'activejob-6.0.x' do gem 'activejob', '~> 6.0.5' end appraise 'activejob-6.1.x' do gem 'activejob', '~> 6.1.6' end appraise 'activejob-7.0.x' d...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
activejob-uniqueness.gemspec
Ruby
mit
302
main
1,525
# frozen_string_literal: true lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'active_job/uniqueness/version' Gem::Specification.new do |spec| spec.name = 'activejob-uniqueness' spec.version = ActiveJob::Uniqueness::VERSION spec.authors ...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/spec_helper.rb
Ruby
mit
302
main
885
# frozen_string_literal: true require 'bundler/setup' require 'pry-byebug' require 'active_support/core_ext/kernel/reporting' begin require 'sidekiq/api' rescue LoadError require 'active_job/uniqueness' else require 'active_job/uniqueness/sidekiq_patch' end Dir['./spec/support/**/*.rb'].sort.each { |f| require...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/support/log_helpers.rb
Ruby
mit
302
main
591
# frozen_string_literal: true RSpec::Matchers.define :log do |expected| match do |actual| log = StringIO.new logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(log)) allow(ActiveJob::Base).to receive(:logger).and_return(logger) allow_any_instance_of(ActiveJob::Base).to receive(...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/support/classes_helpers.rb
Ruby
mit
302
main
685
# frozen_string_literal: true module ClassesHelpers def stub_active_job_class(name = 'MyJob', &block) klass = Class.new(ActiveJob::Base) klass.class_eval(&block) if block_given? stub_const(name, klass) end def stub_sidekiq_class(name = 'MySidekiqWorker', &block) klass = Class.new klass.inclu...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/support/redis_helpers.rb
Ruby
mit
302
main
222
# frozen_string_literal: true module RedisHelpers def redis @redis ||= RedisClient.new(url: ENV.fetch('REDIS_URL', 'redis://localhost:6379')) end end RSpec.configure do |config| config.include RedisHelpers end
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/support/locks_helpers.rb
Ruby
mit
302
main
1,970
# frozen_string_literal: true module LocksHelpers def cleanup_locks(**args) ActiveJob::Uniqueness.unlock!(**args) end def locks(**args) redis.call('KEYS', ActiveJob::Uniqueness::LockKey.new(**args).wildcard_key) end def locks_count locks.count end def locks_expirations(**args) locks(**...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/support/active_job.rb
Ruby
mit
302
main
359
# frozen_string_literal: true ActiveJob::Base.queue_adapter = :test ActiveJob::Base.logger = ActiveSupport::TaggedLogging.new(Logger.new(nil)) # Silence noisy deprecation warnings case ActiveJob::VERSION::STRING.to_f when 6.0 ActiveJob::Base.return_false_on_aborted_enqueue = true when 6.1 ActiveJob::Base.skip_af...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/support/active_job_helpers.rb
Ruby
mit
302
main
812
# frozen_string_literal: true module ActiveJobHelpers def clear_enqueued_jobs enqueued_jobs.clear end def perform_enqueued_jobs enqueued_jobs.each do |job| job[:job].new(*job[:args]).perform_now end end def enqueued_jobs ActiveJob::Base.queue_adapter.enqueued_jobs end def test_ad...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/support/shared_examples/unlocking.rb
Ruby
mit
302
main
470
# frozen_string_literal: true shared_examples_for 'no unlock attempts' do it 'does not try to unset any locks', :aggregate_failures do allow(ActiveJob::Uniqueness.lock_manager).to receive(:delete_locks) allow(ActiveJob::Uniqueness.lock_manager).to receive(:delete_lock) subject expect(ActiveJob::Uni...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/support/shared_examples/enqueuing.rb
Ruby
mit
302
main
6,224
# frozen_string_literal: true shared_examples_for 'a strategy with unique jobs in the queue' do describe 'enqueuing' do subject { job_class.perform_later(*arguments) } let(:arguments) { [1, 2] } let(:job_class) { stub_active_job_class } context 'when enqueuing has succeed' do shared_examples...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/active_job/uniqueness/configure_spec.rb
Ruby
mit
302
main
3,123
# frozen_string_literal: true describe ActiveJob::Uniqueness, '.configure' do let(:config) { ActiveJob::Uniqueness::Configuration.new } let(:redis_url) { ENV.fetch('REDIS_URL', 'redis://localhost:6379') } before { allow(described_class).to receive(:config).and_return config } context 'when no configuration h...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/active_job/uniqueness/test_mode_spec.rb
Ruby
mit
302
main
570
# frozen_string_literal: true describe ActiveJob::Uniqueness, '.test_mode!', type: :integration do let(:job_class) do stub_active_job_class('MyJob') do unique :until_expired end end before do described_class.test_mode! end after do described_class.reset_manager! end it "doesn't l...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/active_job/uniqueness/unlock_spec.rb
Ruby
mit
302
main
2,867
# frozen_string_literal: true describe ActiveJob::Uniqueness, '.unlock!', type: :integration do let(:job_class) do stub_active_job_class('MyJob') do unique :until_expired end end let(:other_job_class) do stub_active_job_class('MyOtherJob') do unique :until_expired end end before...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/active_job/uniqueness/sidekiq_patch_spec.rb
Ruby
mit
302
main
3,409
# frozen_string_literal: true describe 'Sidekiq patch', :sidekiq, type: :integration do shared_examples_for 'locks release' do let(:sidekiq_worker) { stub_sidekiq_class } after { Sidekiq::Queue.all.each(&:clear) } context 'when queue adapter is Sidekiq', active_job_adapter: :sidekiq do context 'w...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/active_job/uniqueness/lock_key/new_spec.rb
Ruby
mit
302
main
1,182
# frozen_string_literal: true describe ActiveJob::Uniqueness::LockKey, '.new' do context 'when no job_class_name given' do context 'when arguments given' do subject(:initialize_lock_key) { described_class.new(arguments: [1, 2]) } it 'raises ArgumentError' do expect { initialize_lock_key }.to...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/active_job/uniqueness/lock_key/lock_key_spec.rb
Ruby
mit
302
main
1,445
# frozen_string_literal: true describe ActiveJob::Uniqueness::LockKey, '#lock_key' do subject { lock_key.lock_key } let(:lock_key) { described_class.new(job_class_name: job_class_name, arguments: arguments) } let(:job_class_name) { 'FooBarJob' } let(:arguments) { ['baz'] } context 'when default configurati...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/active_job/uniqueness/lock_key/wildcard_key_spec.rb
Ruby
mit
302
main
962
# frozen_string_literal: true describe ActiveJob::Uniqueness::LockKey, '#wildcard_key' do subject { lock_key.wildcard_key } context 'when job_class_name is given' do context 'when no arguments given' do let(:lock_key) { described_class.new(job_class_name: 'FooJob') } it { is_expected.to eq 'activ...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/active_job/uniqueness/lock_key/runtime_lock_key_spec.rb
Ruby
mit
302
main
1,509
# frozen_string_literal: true describe ActiveJob::Uniqueness::LockKey, '#runtime_lock_key' do subject { lock_key.runtime_lock_key } let(:lock_key) { described_class.new(job_class_name: job_class_name, arguments: arguments) } let(:job_class_name) { 'FooBarJob' } let(:arguments) { ['baz'] } context 'when def...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/active_job/uniqueness/strategies/until_expired_spec.rb
Ruby
mit
302
main
2,331
# frozen_string_literal: true describe ':until_expired strategy', type: :integration do it_behaves_like 'a strategy with unique jobs in the queue' do let(:strategy) { :until_expired } end describe 'performing' do subject(:process) { perform_enqueued_jobs } let(:job_class) do stub_active_job_c...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/active_job/uniqueness/strategies/while_executing_spec.rb
Ruby
mit
302
main
5,210
# frozen_string_literal: true describe ':while_executing strategy', type: :integration do it_behaves_like 'a strategy with non unique jobs in the queue' do let(:strategy) { :while_executing } end describe 'processing' do subject(:process) { perform_enqueued_jobs } let(:job_class) do stub_acti...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/active_job/uniqueness/strategies/until_executed_spec.rb
Ruby
mit
302
main
2,312
# frozen_string_literal: true describe ':until_executed strategy', type: :integration do it_behaves_like 'a strategy with unique jobs in the queue' do let(:strategy) { :until_executed } end describe 'performing' do subject(:process) { perform_enqueued_jobs } let(:job_class) do stub_active_job...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/active_job/uniqueness/strategies/until_and_while_executing_spec.rb
Ruby
mit
302
main
8,611
# frozen_string_literal: true describe ':until_and_while_executing strategy', type: :integration do it_behaves_like 'a strategy with unique jobs in the queue' do let(:strategy) { :until_and_while_executing } end describe 'processing' do subject(:process) { perform_enqueued_jobs } let(:job_class) do...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/active_job/uniqueness/strategies/until_executing_spec.rb
Ruby
mit
302
main
2,293
# frozen_string_literal: true describe ':until_executing strategy', type: :integration do it_behaves_like 'a strategy with unique jobs in the queue' do let(:strategy) { :until_executing } end describe 'performing' do subject(:process) { perform_enqueued_jobs } let(:job_class) do stub_active_j...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/active_job/uniqueness/active_job_patch/unique_spec.rb
Ruby
mit
302
main
5,815
# frozen_string_literal: true describe ActiveJob::Uniqueness::ActiveJobPatch, '.unique' do let(:job_class) { stub_active_job_class } context 'when an custom strategy is given' do context 'when matching custom strategy is configured' do subject(:make_job_unique) { job_class.unique :custom, foo: 'bar' } ...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
spec/active_job/uniqueness/active_job_patch/unlock_spec.rb
Ruby
mit
302
main
1,613
# frozen_string_literal: true describe ActiveJob::Uniqueness::ActiveJobPatch, '.unlock!', type: :integration do let(:job_class) do stub_active_job_class('MyJob') do unique :until_expired end end let(:another_job_class) do stub_active_job_class('MyAnotherJob') do unique :until_expired ...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
lib/active_job/uniqueness.rb
Ruby
mit
302
main
1,066
# frozen_string_literal: true require 'active_job' require 'redlock' require 'active_job/uniqueness/version' require 'active_job/uniqueness/errors' require 'active_job/uniqueness/log_subscriber' require 'active_job/uniqueness/active_job_patch' module ActiveJob module Uniqueness extend ActiveSupport::Autoload ...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
lib/active_job/uniqueness/strategies.rb
Ruby
mit
302
main
848
# frozen_string_literal: true module ActiveJob module Uniqueness # See Configuration#lock_strategies if you want to define custom strategy module Strategies extend ActiveSupport::Autoload autoload :Base autoload :UntilExpired autoload :UntilExecuted autoload :UntilExecuting ...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
lib/active_job/uniqueness/errors.rb
Ruby
mit
302
main
938
# frozen_string_literal: true module ActiveJob module Uniqueness class Error < ::RuntimeError; end # Raised when unknown strategy is referenced in the job class # # class MyJob < ActiveJob::Base # unique :invalid_strategy # exception raised # end # class StrategyNotFound < Error; e...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
lib/active_job/uniqueness/test_lock_manager.rb
Ruby
mit
302
main
317
# frozen_string_literal: true module ActiveJob module Uniqueness # Mocks ActiveJob::Uniqueness::LockManager methods. # See ActiveJob::Uniqueness.test_mode! class TestLockManager def lock(*_args) true end alias delete_lock lock alias delete_locks lock end end end
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
lib/active_job/uniqueness/active_job_patch.rb
Ruby
mit
302
main
2,920
# frozen_string_literal: true module ActiveJob module Uniqueness # Provides ability to make ActiveJob job unique. # # For example: # # class FooJob < ActiveJob::Base # queue_as :foo # # unique :until_executed, lock_ttl: 3.hours # # def perform(params) # #... ...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
lib/active_job/uniqueness/log_subscriber.rb
Ruby
mit
302
main
2,386
# frozen_string_literal: true require 'active_support/log_subscriber' module ActiveJob module Uniqueness class LogSubscriber < ActiveSupport::LogSubscriber # :nodoc: def lock(event) job = event.payload[:job] resource = event.payload[:resource] debug do "Locked #{lock_inf...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
lib/active_job/uniqueness/lock_key.rb
Ruby
mit
302
main
1,744
# frozen_string_literal: true require 'active_job/arguments' module ActiveJob module Uniqueness class LockKey FALLBACK_ARGUMENTS_STRING = 'no_arguments' delegate :lock_prefix, :digest_method, to: :'ActiveJob::Uniqueness.config' attr_reader :job_class_name, :arguments def initialize(jo...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
lib/active_job/uniqueness/sidekiq_patch.rb
Ruby
mit
302
main
2,902
# frozen_string_literal: true require 'activejob/uniqueness' require 'sidekiq/api' module ActiveJob module Uniqueness def self.unlock_sidekiq_job!(job_data) return unless job_data['class'] == 'ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper' # non ActiveJob jobs job = ActiveJob::Base.deseriali...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
lib/active_job/uniqueness/configuration.rb
Ruby
mit
302
main
1,679
# frozen_string_literal: true module ActiveJob module Uniqueness # Use /config/initializer/activejob_uniqueness.rb to configure ActiveJob::Uniqueness # # ActiveJob::Uniqueness.configure do |c| # c.lock_ttl = 3.hours # end # class Configuration include ActiveSupport::Configurable ...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
lib/active_job/uniqueness/lock_manager.rb
Ruby
mit
302
main
1,391
# frozen_string_literal: true module ActiveJob module Uniqueness # Redlock requires a value of the lock to release the resource by Redlock::Client#unlock method. # LockManager introduces LockManager#delete_lock to unlock by resource key only. # See https://github.com/leandromoreira/redlock-rb/issues/51 f...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
lib/active_job/uniqueness/strategies/base.rb
Ruby
mit
302
main
4,051
# frozen_string_literal: true module ActiveJob module Uniqueness module Strategies # Base strategy is not supposed to actually be used as uniqueness strategy. class Base # https://github.com/rails/rails/pull/17227 # https://groups.google.com/g/rubyonrails-core/c/mhD4T90g0G4 AC...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
lib/active_job/uniqueness/strategies/until_expired.rb
Ruby
mit
302
main
301
# frozen_string_literal: true module ActiveJob module Uniqueness module Strategies # Locks the job when it is pushed to the queue. # Does not allow new jobs enqueued until lock is expired. class UntilExpired < Base include LockingOnEnqueue end end end end
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
lib/active_job/uniqueness/strategies/while_executing.rb
Ruby
mit
302
main
710
# frozen_string_literal: true module ActiveJob module Uniqueness module Strategies # Locks the job when the job starts. # Unlocks the job when the job is finished. class WhileExecuting < Base def before_perform return if lock(resource: lock_key, ttl: lock_ttl, event: :runtime_...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
lib/active_job/uniqueness/strategies/until_executing.rb
Ruby
mit
302
main
367
# frozen_string_literal: true module ActiveJob module Uniqueness module Strategies # Locks the job when it is pushed to the queue. # Unlocks the job before the job is started. class UntilExecuting < Base include LockingOnEnqueue def before_perform unlock(resource: loc...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
lib/active_job/uniqueness/strategies/until_executed.rb
Ruby
mit
302
main
364
# frozen_string_literal: true module ActiveJob module Uniqueness module Strategies # Locks the job when it is pushed to the queue. # Unlocks the job when the job is finished. class UntilExecuted < Base include LockingOnEnqueue def after_perform unlock(resource: lock_k...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
lib/active_job/uniqueness/strategies/until_and_while_executing.rb
Ruby
mit
302
main
1,388
# frozen_string_literal: true module ActiveJob module Uniqueness module Strategies # Locks the job when it is pushed to the queue. # Unlocks the job before the job is started. # Then creates runtime lock to prevent simultaneous jobs from being executed. class UntilAndWhileExecuting < Base...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
lib/generators/active_job/uniqueness/install_generator.rb
Ruby
mit
302
main
391
# frozen_string_literal: true module ActiveJob module Uniqueness module Generators class InstallGenerator < Rails::Generators::Base desc 'Copy ActiveJob::Uniqueness default files' source_root File.expand_path('templates', __dir__) def copy_config template 'config/initiali...
github
veeqo/activejob-uniqueness
https://github.com/veeqo/activejob-uniqueness
lib/generators/active_job/uniqueness/templates/config/initializers/active_job_uniqueness.rb
Ruby
mit
302
main
1,911
# frozen_string_literal: true ActiveJob::Uniqueness.configure do |config| # Global default expiration for lock keys. Each job can define its own ttl via :lock_ttl option. # Strategy :until_and_while_executing also accepts :on_runtime_ttl option. # # config.lock_ttl = 1.day # Prefix for lock keys. Can not be...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
Rakefile
Ruby
apache-2.0
302
master
289
# encoding: utf-8 require 'bundler' Bundler::GemHelper.install_tasks require 'rspec/core/rake_task' desc 'Default: run unit tests.' task :default => :spec desc "Run all specs" RSpec::Core::RakeTask.new do |t| t.pattern = 'spec/**/*_spec.rb' t.rspec_opts = ["-c", "-f progress"] end
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
Guardfile
Ruby
apache-2.0
302
master
1,282
# A sample Guardfile # More info at https://github.com/guard/guard#readme ## Uncomment and set this to only include directories you want to watch # directories %w(app lib config test spec features) \ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")} ## Note: if you are using the `direct...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
couchrest_model.gemspec
Ruby
apache-2.0
302
master
1,786
Gem::Specification.new do |s| s.name = %q{couchrest_model} s.version = `cat VERSION`.strip s.license = "Apache License 2.0" s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version= s.authors = ["J. Chris Anderson", "Matt Aimonetti", "Marcos Tapajos", "Will Le...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest_model.rb
Ruby
apache-2.0
302
master
2,065
require "active_model" require "active_model/callbacks" require "active_model/conversion" require "active_model/errors" require "active_model/naming" require "active_model/serialization" require "active_model/translation" require "active_model/validator" require "active_model/validations" require "active_model/dirty" ...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/tasks/migrations.rake
Ruby
apache-2.0
302
master
1,083
# # CouchRest Migration Rake Tasks # # See the CouchRest::Model::Utils::Migrate class for more details. # namespace :couchrest do namespace :designs do desc "Migrate all the design docs found in each model" task :migrate => :environment do CouchRest::Model::Utils::Migrate.load_all_models CouchRe...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/railtie.rb
Ruby
apache-2.0
302
master
908
require "rails" require "active_model/railtie" module CouchRest class ModelRailtie < Rails::Railtie def self.generator config.respond_to?(:app_generators) ? :app_generators : :generators end config.send(generator).orm :couchrest_model config.send(generator).test_framework :test_unit, :fixture...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/embeddable.rb
Ruby
apache-2.0
302
master
1,783
module CouchRest::Model module Embeddable extend ActiveSupport::Concern # Include Attributes early to ensure super() will work include CouchRest::Attributes included do include CouchRest::Model::Configuration include CouchRest::Model::Properties include CouchRest::Model::PropertyPr...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/design.rb
Ruby
apache-2.0
302
master
5,024
module CouchRest module Model class Design < ::CouchRest::Design include ::CouchRest::Model::Designs::Migrations # The model Class that this design belongs to and method name attr_accessor :model, :method_name # Can this design save itself to the database? # If false, the design w...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/designs.rb
Ruby
apache-2.0
302
master
3,122
#### NOTE Work in progress! Not yet used! module CouchRest module Model # A design block in CouchRest Model groups together the functionality of CouchDB's # design documents in a simple block definition. # # class Person < CouchRest::Model::Base # property :name # timestamps! #...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/base.rb
Ruby
apache-2.0
302
master
2,823
module CouchRest module Model class Base < CouchRest::Document include ActiveModel::Conversion extend Translation include Configuration include Connection include Persistence include DocumentQueries include ExtendedAttachments include Proxyable include Prop...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/validations.rb
Ruby
apache-2.0
302
master
2,683
# encoding: utf-8 require "couchrest/model/validations/casted_model" require "couchrest/model/validations/uniqueness" I18n.load_path << File.join( File.dirname(__FILE__), "validations", "locale", "en.yml" ) module CouchRest module Model # Validations may be applied to both Model::Base and Model::CastedModel...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/typecast.rb
Ruby
apache-2.0
302
master
5,283
module CouchRest module Model module Typecast def typecast_value(parent, property, value) return nil if value.nil? type = property.type if value.instance_of?(type) || type == Object if type == Time && !value.utc? value.utc # Ensure Time is always in UTC ...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/translation.rb
Ruby
apache-2.0
302
master
447
module CouchRest module Model module Translation include ActiveModel::Translation def lookup_ancestors #:nodoc: klass = self classes = [klass] return classes if klass == CouchRest::Model::Base while klass.superclass != CouchRest::Model::Base classes << klass...
github
couchrest/couchrest_model
https://github.com/couchrest/couchrest_model
lib/couchrest/model/configuration.rb
Ruby
apache-2.0
302
master
2,257
module CouchRest # CouchRest Model Configuration support, stolen from Carrierwave by jnicklas # http://github.com/jnicklas/carrierwave/blob/master/lib/carrierwave/uploader/configuration.rb module Model module Configuration extend ActiveSupport::Concern included do add_config :model_t...