text
stringlengths
10
2.61M
# frozen_string_literal: true RSpec.describe Membership, type: :model do let(:user) { build(:user) } let(:admin) { build(:user, :admin) } before do user.save! admin.save! end describe 'membership addition' do subject(:add_membership!) { user.add_membership!(admin) } it 'creates extra build...
class TracksController < ApplicationController def index if params[:artist_id] @tracks = Track.where(artist_id: params[:artist_id]) else @tracks = Track.identified_tracks end render json: @tracks, status: 200 end def show @track = Track.find(...
# == Schema Information # # Table name: users # # id :integer not null, primary key # username :string(50) not null # email :string(100) not null # password_digest :string(60) # last_sign_in :datetime # admin :boolean default(FALSE), not null...
class UsersController < ApplicationController skip_before_filter :login_required, :only => [ :new, :create ] def index @user = User.users_descending end def show #make general #if @logged_user_id == params[:id] @user = User.find(params[:id]) #else # flash[:warning] = "Ai pyrit kielletylle sivulle."...
require 'spec_helper' describe ClubNightsController do let(:user) { FactoryGirl.create(:confirmed_user) } let!(:club_night) { user.club_nights.create(FactoryGirl.attributes_for(:club_night)) } before do sign_in(:user, user) end describe "#new" do it "successfully renders new" do get :new ...
# frozen_string_literal: true require "test_prof/factory_prof/factory_bot_patch" require "test_prof/factory_bot" module TestProf module FactoryProf module FactoryBuilders # implementation of #patch and #track methods # to provide unified interface for all factory-building gems class FactoryBot...
require 'spec_helper' require 'feedjira' describe JobListing do context '.create_from_atom' do let(:atom_feed) { fixture('newton_feed.xml') } let(:parsed_feed) { Feedjira::Feed.parse(atom_feed) } let(:atom_entry) { parsed_feed.entries.first } before do FeedjiraHelper.add_common_feed_entry_el...
class Wine < ActiveRecord::Base VARIETALS = ['Merlot', 'Chianti', 'Chardonnay', 'Cabernet Sauvignon', 'Champagne', 'Bordeaux Blend', 'Pinot Noir', 'Riesling', 'Cava', 'Pinot Grigio'] validates :name, :year, :country, presence: true validates :year, numericality: { only_integer: true }, if: "year.presen...
Rails.application.routes.draw do #root route root 'posts#index', as: 'home' # Regular route get 'about' => 'pages#about', as: 'about' # Resource route (maps the HTTP verbs into controller actions) resources :posts do resources :comments #comments are found inside the post end end
require_relative 'spec_helper' describe 'mantain same user' do before do @user = instance_factory(:user) end it 'true should be true' do expect(@user).to eq instance_factory(:user) end end
class AutolsNginxModule < Formula desc "Flexible nginx auto index module" homepage "https://github.com/DvdKhl/ngx_http_autols_module" url "https://github.com/DvdKhl/ngx_http_autols_module/archive/e0da4b2ff3.tar.gz" sha256 "445c5f3ce494f253afe09de7f418fb076ac9aa5c76083a4186e863156fa9d9fc" bottle :unneeded ...
require 'open-uri' require 'nokogiri' module FD class API ROOT_URL = 'http://www.frieschdagblad.nl/' MONTHS = [nil, 'januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'] def self.articles_for date url = "index.asp?pagina=krantv...
class Solution < ActiveRecord::Base belongs_to :task belongs_to :lecture validates :body, presence: true validates :task_id, presence: true end
require_relative "spec_helper" require_relative "../app/widgets/main.rb" describe "main" do describe "when opening the main app" do before do @app = Qt::Application.new(ARGV) end it "must instanciate an app" do @app.wont_be_nil end # after do # @app.dispose! # end ...
require 'rails_helper' describe ImageService do it "returns image information" do name = "tomato garden" image_data = ImageService.new_image(name) expect(image_data).to be_a(String) end it "returns nil if no image found" do name = "kjdhfkjashfkjhaskjdfhaksh" image_data = ImageService.new_...
class ModifyStock < ActiveRecord::Migration def up rename_column :stocks,:base_mu,:base_rate remove_column :stocks,:base_probability end def down end end
class EnrollmentsController < ApplicationController before_action :set_enrollment, only: [:show, :update, :destroy] respond_to :json, :html def index # respond_with enrollment: Enrollment.all, instructor_name: @instructor_name @enrollment = Enrollment.all respond_with @enrollment.to_json( :inc...
# encoding: utf-8 # Original GEM: https://github.com/feedreader/jekyll-planet/blob/master/lib/jekyll/planet/tool.rb # Released under Public License: https://github.com/feedreader/jekyll-planet#license module JekyllPlanet def self.run( args ) Tool.new.run( args ) end def self.main self.run( ARGV ) end...
require 'test_helper' class ReproductionTest < MiniTest::Unit::TestCase def setup @reproduction = Reproduction.new end def test_dead_cell_in_reproduction dead_cell = Cell.new('-') dead_cell.alive_neighbours_count = 3 dead_cell = @reproduction.apply(dead_cell) assert dead_cell.alive...
class TreasureHunt attr_accessor :boardMap, :currPlayer, :turnAmount, :gemValue, :rareGemValue, :coinValue, :mapWidth, :mapHeight, :coinAmount, :gemAmount, :gemLocations, :gemsFound, :coinsFound, :rareGemFound, :recordNumbers NONE = 0 COIN = 1 GEM = 2 GEM_PIECE = 3 RARE_GEM = 4 de...
class Entry < ActiveRecord::Base belongs_to :project validates :hours, numericality: {only_integer:true}, presence: true validates :minutes, numericality: {only_integer:true}, presence:true validates :date, presence:true validate :project_id, presence:true end
require 'test_helper' class VariablecostValuesControllerTest < ActionDispatch::IntegrationTest setup do @variablecost_value = variablecost_values(:one) end test "should get index" do get variablecost_values_url assert_response :success end test "should get new" do get new_variablecost_value...
class DiningType < ApplicationRecord belongs_to :restaurant_dining_type validates :name, presence: true validates :restaurant_dining_type, presence: true end
class Vlc < Cask url 'http://get.videolan.org/vlc/2.1.2/macosx/vlc-2.1.2.dmg' homepage 'http://www.videolan.org/vlc/' version '2.1.2' sha1 '2a4dceba046682a0f56528045ed637aacae03a33' link 'VLC.app' end
require 'helper_frank' module Rdomino describe Rdomino do NOTESDAT = '!!c:\\_rdomino\\data\\' describe '#environmentalise' do it "production" do Rdomino.production Rdomino.environmentalise('s!!p\file.nsf').must_equal 's!!p\file.nsf' end it "test" do Rdomino.test ...
class Neighborhood < ActiveRecord::Base has_and_belongs_to_many :locations has_many :businesses, through: :locations end
class Task attr_reader :name def initialize(name) @name = name end def get_time_required 0.0 end end class CompositeTask < Task def initialize(name) super @subtasks = [] end def <<(task) @subtasks << task end def delete_task(task) @subtasks.delete(task) end def get_...
class MessagesController < ApplicationController #before_filter :protect_resource def create respond_to do |format| format.json { @new_message = Message.new @new_message.body = params[:body] @new_message.title = "" @new_message.recipient_id = params[:recipient_id] ...
class CreateCompanies < ActiveRecord::Migration def change create_table :companies do |t| t.text :name, uniqueness: true t.text :description t.text :url t.text :job_url t.text :job_page t.integer :applied_count t.timestamps null: false end end end
require 'rails_helper' RSpec.describe User, type: :model do before do @user = FactoryBot.build(:user) end describe 'ユーザー新規登録' do context '新規登録がうまくいかない時' do it "nicknameが空だと登録できない" do @user.nickname = "" @user.valid? expect(@user.errors.full_messages).to include("Nickname can...
RSpec.describe Knuckles::Stages::Combiner do describe ".call" do it "merges all results into a single object" do prepared = [ { result: { author: {id: 1, name: "Michael"}, posts: [{id: 1, title: "hello", tag_ids: [1, 2]}], tags: [{id: 1, name: "alpha"}, ...
require "vanity/experiment/definition" module Vanity module Experiment # Base class that all experiment types are derived from. class Base class << self # Returns the type of this class as a symbol (e.g. AbTest becomes # ab_test). def type name.split("::").last.gsub(/(...
class Album < ActiveRecord::Base PERFORMANCE_TYPES = %w(studio live) enum performance_type: [ :studio, :live ] belongs_to :band has_many :tracks, dependent: :destroy validates :band_id, :performance_type, :title, presence: true validates :performance_type, inclusion: { in: Album.performance_types.keys } v...
class User attr_reader :name @@all = [] def initialize(name) @name=name @@all << self unless @@all.any?(self) end def self.all @@all end def users_pledges Pledge.all.select { |pledge| pledge.user == self} end def self.highest_pledge highest...
module DJ class Worker attr_accessor :user_id class << self # Tell DJ to only allow one of this worker at a given time. # # Example: # # We only want to charge the card once! # class PurchaseWorker < DJ::Worker # is_unique # # def perf...
# Let's define a Tree Tree = Algebrick.type do |tree| variants Empty = atom, Leaf = type { fields Integer }, Node = type { fields tree, tree } end # Now types `Tree(Empty | Leaf | Node)`, `Empty`, `Leaf(Integer)` and `Node(Tree, Tree)` are defined. # Let's add a method, don't miss the **patte...
require "rails_helper" feature "Comments List" do let(:article) { create(:article) } let!(:comments) { create_list(:comment, 2, article: article) } let(:comment) { comments.last } background do visit article_path(article) end scenario "Visitor doesn't show comment form" do expect(page).not_to hav...
class ApplicationController < ActionController::Base protect_from_forgery with: :exception before_action :set_cache_headers def after_sign_in_path_for(resource) dashboard_path(current_user) end def set_cache_headers response.headers["Cache-Control"]="no-cache,no-store,max-age=0,must-revalidate" ...
#encoding: utf-8 #GIVEN Given("that there is a registered user license") do steps %Q{ Given that the user wants to create a new license And the authorization token has already been generated When the app makes a HTTP POST request to the user license service Then the response code should be "200" ...
module Starfish module UrlHelpers def current_path request.fullpath end def setup_path "/setup" end def authentication_path "/auth/github" end def projects_path "/projects" end def project_path(project) ["/projects", project.slug].join("/") end...
# Creates SpnEvent objects with scraped info from SPN Event Calendar. require_relative '../spn_scraper.rb' require_relative '../startup_lincoln_scraper.rb' require_relative '../tech_omaha_scraper.rb' namespace :event do desc "Scrape for Events" task :all => :environment do StartupLincolnScraper.scrape Tech...
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). # # Examples: # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # ...
module Core module Model module Preferences module Preferable extend ActiveSupport::Concern included do if respond_to?(:after_create) after_create do |obj| obj.save_pending_preferences end end if respond_to?(:after...
# Write a method that takes one argument, a positive integer, and returns a list of the digits in the number. def digit_list(number) number.to_s.split("").map { |num| num.to_i } # -------- # numbers = [] # loop do # number, remainder = number.divmod(10) # numbers.unshift(remainder) # break if number == 0...
module Refinery module Brokers class Broker < Refinery::Core::BaseModel self.table_name = 'refinery_brokers' attr_accessible :name, :title, :email, :phone, :fax, :headshot_id, :bio, :is_broker, :rank, :position acts_as_indexed :fields => [:name, :title, :email, :phone, :fax, :bio] valid...
require 'rails_helper' RSpec.describe Product, type: :model do # Use .alphabetical because it's a class method. Example: Product.alphabetical # Use #long_name when #long_name is an instance method. Example: @product.long_name describe ".alphabetical" do it "returns [] when there are no products" do e...
class User < ActiveRecord::Base validates :name, :email, presence: true has_many :post end
class Province < ActiveRecord::Base has_many :cities has_many :users def self.cache_find(id) return nil if !id begin c = $cache.get("province_#{id}") rescue Memcached::NotFound => e c = Province.find_by_id(id) $cache.set("province_#{id}", c) rescue c = Province.find_by_id(i...
require "a1539kh_practice/version" module A1539khPractice class Main #整数を入力として受け取り,値が奇数ならば真を返す def odd?(num) !num.even? rescue ArgumentError false end #引数が0 以外ではじまる4 桁の数字であり,なおかつ,値が偶数ならば真を返す def check_number?(str) num = Integer(str) if num.to_s.length == 4 && num.even...
class ChangeLimitStockTypeToStockHolds < ActiveRecord::Migration[5.0] def change change_column(:stock_holds, :stock_type, :string) end end
class Plateau attr_accessor :number_of_landed_rovers, :x_axis_max, :y_axis_max def initialize @number_of_landed_rovers = 0 @x_axis_max = nil @y_axis_max = nil end def grid_size "Maximum point on x-axis is #{x_axis_max}.\nMaximum point on y-axis is #{y_axis_max}." ...
# encoding: utf-8 require File.expand_path("../spec_helper", __FILE__) describe "TextField" do before :each do browser.goto(WatirSpec.files + "/forms_with_input_elements.html") end # Exists method describe "#exists?" do it "returns true if the element exists" do browser.text_field(:id, 'new_use...
require 'test_helper' class ImagesControllerTest < ActionDispatch::IntegrationTest def test_new get new_image_path assert_response :ok end def test_create__success assert_difference('Image.count', 1) do post images_path, params: image_params end assert_redirected_to image_path(id: Imag...
class Asteroids::VelocityComponent include Gamey::Component attr_accessor :linear_velocity, :angular_velocity def initialize @linear_velocity = Gamey::Vector2.new @angular_velocity = 0 end end
Rails.application.routes.draw do get 'users/sign_in' => 'sessions#new' post 'users/sign_in' => 'sessions#create' get 'users/sign_up' => 'users#new' delete 'log_out' => 'sessions#destroy' resources :users resources :posts resources :categories root 'static_pages#home' # For details on the DSL available...
# frozen_string_literal: true class Filter OperatorValueInvalid = Class.new(StandardError) UnknownFilter = Class.new(StandardError) class << self attr_accessor :table def apply(relation, filters) base = new(relation) filters.each do |f| base = base.filter(f[:field], f[:op], f[:value...
require 'thor' require 'scaffold/subcommand/example' module Scaffold # Implements a Thor based command-line interface for Scaffold. class Cli < Thor # Load the 'example' subcommand into the Cli scope. desc 'example [COMMAND]', 'example subcommands' subcommand 'example', Scaffold::Subcommand::Example ...
require File.join(File.dirname(__FILE__), '..', 'review') describe Review do let(:params){{:image_url => 'http://twitpic.com/eRR323', :text => 'paprika is a dark, shady and creepy place', :like => false, :latitude => 303.121, :longitude => 102.22, :created_at => '20...
class AddHeaderToUsers < ActiveRecord::Migration def change add_column :users, :header, :text end end
require "spec_helper" describe Nilist do context "when sent a message from Object's interface" do describe "#instance_of?" do it "raises UnprovableError" do nilist = Nilist.new expect { nilist.instance_of? Nilist }.to raise_error(UnprovableError) end end describe "#kind_of?"...
class DocumentsController < ApplicationController before_filter :check_cancel, :only => [:create, :update] before_filter :load_document, :only => [:show, :edit, :update, :destroy] def index @query = params[:query] ? Regexp.escape(params[:query]) : "" page = (params[:page].to_i > 0) ? params[:page] : 1 ...
require 'rexml/document' class TkXML # def parse(source) listener = REXML_Listener.new(self) REXML::Document.parse_stream(source, listener) end # REXML Listener class REXML_Listener # attr :tk # def initialize(tk) super() @tk = tk end # def tag_start(name,...
class Episode < ActiveRecord::Base validates_uniqueness_of :number_in_season, scope: :season validates_uniqueness_of :production_code validates_presence_of :season, :number_in_series, :number_in_season, :title, :original_air_date, :production_code has_many :script_lines, -> { order(:number) } WIKIPEDIA_EPIS...
class Converter def initialize(raw_input) @raw_input = raw_input @output = "" end def check_input() var_type = @raw_input.instance_of? Integer if var_type == true if @raw_input <= 0 raise StandardError.new, "Input variable should be a positive int...
module LD4L module OreRDF class ProxyResource < ActiveTriples::Resource class << self; attr_reader :localname_prefix end @localname_prefix="px" # configure :base_uri => LD4L::OreRDF.configuration.base_uri, repository => :default configure :type => RDFVocabularies::ORE.Proxy, :base_uri =>...
class CreateTableGames < ActiveRecord::Migration def change create_table :table_games do |t| t.string :name t.string :description t.integer :suitable_persons t.integer :price_min t.integer :price_max t.integer :recommendation t.timestamps null: false end end end
class RockPaperScissorsController < ApplicationController def new @computer_hands = computer_hands end def show @computer_hand = computer_hands.sample @chosen_hand = params[:id] @player_won = is_winner?(@computer_hand, @chosen_hand) if @player_won == 'wat' puts 'wat' elsif @player_...
require 'rails/rack/log/level/version' require 'rails/rack/log/level/rule' require 'rails/rack/log/level/rule_set' module Rails module Rack module Log class Level # Your code goes here... def initialize(app, given_options = {}, &rule_block) options = { klass: RuleSet, ...
# frozen_string_literal: true class ApplicationController < ActionController::Base protect_from_forgery with: :exception add_flash_types :success, :error include Application::Meta include Application::LayoutAndFormatting include Application::Security include MarkdownHelper include ApplicationHelper in...
module Inspec VERSION = "4.29.4".freeze end
class Review < ApplicationRecord has_many :reviews_tags, dependent: :destroy has_many :tags, through: :reviews_tags has_many :comments, dependent: :destroy has_many :likes, dependent: :destroy belongs_to :user belongs_to :album # 当該レビューに対して、引数に渡したユーザーがいいねを押しているかの判断 def liked_by(user_id) likes.where...
require "httparty" require "dotenv" class CompanyNameGetter include HTTParty base_uri "api.data.gov/sam/v4/" def initialize @api_key = get_api_key end def get_registration(duns) duns = "0#{duns}" if duns.length == 8 duns = "00#{duns}" if duns.length == 7 full_duns = "#{duns}0000" handl...
class UserTellsController < ApplicationController include SetUser include UserConfirmation include UserSignedIn before_action :user_signed_in before_action :set_user before_action :user_confirmation #電話番号の編集機能 def update if @number = @user.number @number.update(user_tell_params) fla...
class CreateOrigins < ActiveRecord::Migration def change create_table :origins do |t| t.integer :originable_id t.string :originable_type t.string :ip t.string :provider t.string :user_agent t.string :locale t.timestamps null: false end add_index :origins, :origin...
require 'rails_helper' RSpec.describe 'Movie Index poros' do it 'has readable attributes' do movie_json = File.read('spec/fixtures/movie.json') data_hash = JSON.parse(movie_json, symbolize_names: true) movie = MovieIndex.new(data_hash) expect(movie.class).to eq(MovieIndex) expect(movie.id).to eq...
require 'spec_helper' describe ProjectTasksController, :type => :routing do describe 'routing' do describe 'routes to #index,' do context 'when using url,' do subject{ { get:'/projects/1/project_tasks' } } it{ is_expected.to be_routable } it{ is_expected.to route_to(controller: 'pro...
class Array # Write a monkey patch of binary search: # E.g. [1, 2, 3, 4, 5, 7].my_bsearch(5) => 4 # **Do NOT use the built in `Array#index` `Array#find_index`, `Array#include?`, # or `Array#member` methods in your implementation.** # NB: YOU MUST WRITE THIS RECURSIVELY (searching half of the array every ti...
class Guest < ApplicationRecord validates :name, presence: true, uniqueness: true validates :email, uniqueness: true, format: { with: /\A[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}\z/i } validates :phone, :numericality => true, :length => { :minimum => 10, :maximum => 10 } end
require_relative 'assert_exec' # Represents a volume created from a # cyberdojo/runner docker container. class RunnerVolume def initialize(name) @name = name end attr_reader :name def id name.split('_')[-1] # eg BB6BDA27C1 end def create assert_exec "docker volume create --name #{name}" ...
# frozen_string_literal: true module GraphQL class Schema class Validator # You can use this to allow certain values for an argument. # # Usually, a {GraphQL::Schema::Enum} is better for this, because it's self-documenting. # # @example only allow certain values for an argument ...
require 'rails_helper' require 'importers' require 'mail_retriever' RSpec.feature 'Importing tp data' do scenario 'Storing daily call volumes for use in the Minister For Pensions report' do when_i_import_tp_data then_the_daily_call_volume_for_tp_should_be_saved end scenario 'Storing tp call record' do ...
class RemoveInheritedColumnsDoctor < ActiveRecord::Migration[5.1] def change remove_column :doctors, :email, :string remove_column :doctors, :salary, :float remove_column :doctors, :name, :string remove_column :employee_records, :type, :string end end
class AddDemokitTable < ActiveRecord::Migration[5.2] def change create_table :demokits do |t| t.integer :user_id t.integer :serial_number t.string :reason t.string :region t.string :tmversion t.string :esxiversion t.string :status t.date :change_date t.text :n...
class IdeasController < ApplicationController respond_to :json, :html def index @ideas = Idea.all.limit(10) respond_with(@ideas) end def create @idea = Idea.create(idea_params) if @idea render json: {"everything":"is alright"} else head :unprocessable_entity end end def idea_params params...
class AddGradeToEssaySolutions < ActiveRecord::Migration[6.1] def change add_column :essay_solutions, :grade, :float end end
class ClubNightMembershipsController < ApplicationController before_filter :authenticate_user! before_filter :find_club_night def new @user = User.new end def create @user = @club_night.users.where(:email => params[:user][:email]).first if @user redirect_to club_night_club_night_membershi...
# frozen_string_literal: true # レビューに対するコインの取引 class ReviewCoinTransaction < ApplicationRecord validates :review_id, uniqueness: { scope: :from } belongs_to :review # 既にそのレビューに対して投げ銭をしているか確認 # ==Arguments # * review_id :: 調べるレビューのID # * user_id :: 調べる渡したユーザーのID # ==Return # * 存在している # => true #...
# factory for generating users for tests FactoryGirl.define do # alias friend is used with friendships and friend requests factory :user, aliases: [:friend_id] do sequence :email do |n| "foo#{n}@bar.com" end password 'foobar' end factory :post do association :user body 'postbody' en...
#!/usr/bin/env ruby # Appends a configuration file, rotating the file for safety. class Appender require 'rubygems' require 'fileutils' require 'yaml' require 'ostruct' require 'logrotate' def self.process(options={}) appender = new appender.process(options) end # Usage: # append_text = ...
class CreateCoursesExamSessions < ActiveRecord::Migration def change create_table :courses_exam_sessions do |t| t.references :course, index: true t.references :exam_session, index: true t.timestamps null: false end add_foreign_key :courses_exam_sessions, :courses add_foreign_key :co...
Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html root 'pages#welcome' mount ActionCable.server => '/cable' get '/signin' => 'pages#login' get '/you-shall-not-pass' => 'pages#pass' get '/login' => 'sessions#new' post '/l...
class CreateDhokebaazSupports < ActiveRecord::Migration def change create_table :dhokebaaz_supports do |t| t.references :dhokebaaz, index: true t.references :user, index: true t.string :ip_address t.text :message t.boolean :post_as_anonymous t.timestamps end end end
class GroupsController < ApplicationController before_filter :verify_editor_permission, :only => [:remove, :add] before_filter :verify_editor_permission_by_id, :only => [:destroy, :edit, :update, :make_public, :make_editable] def verify_editor_permission_by_id redirect_to groups_path unless @current_use...
require 'rails_helper' RSpec.describe Room, type: :model do describe 'Require validations' do it 'should has a name' do should validate_presence_of(:name) end it 'should has a unique name' do should validate_uniqueness_of(:name).case_insensitive end end describe 'Has Associations' d...
require "rails_helper" RSpec.describe AdminHelper, type: :helper do describe "#current_resource_name" do before { expect(helper.request).to receive(:path) { "admin/things/id" } } subject { helper.current_resource_name } it { is_expected.to eq("Thing") } end end
require 'rails_helper' feature "Profile page" do let!(:user) { FactoryGirl.create(:user) } scenario "viewing" do visit user_path(user) expect(page).to have_content(user.name) expect(page).to have_content(user.email) end end feature "Editing Users" do let!(:user) { FactoryGirl.create(:user) } ...
# frozen_string_literal: true class CreateSources < ActiveRecord::Migration[6.0] def change create_table :sources do |t| t.string :slug, null: false t.string :code, null: false t.string :name t.jsonb :details, null: false, default: {} t.timestamps t.index :slug, unique: true...
require 'spec_helper' RSpec.describe Task do it 'Retrieves information from remote' do task_id = task_factory task = Task.create task_id expect(task.id).to eq task_id assert_requested :get, "#{ENV['TASK_SERVER_URL']}/tasks/#{task_id}/" end it 'Recursively syncs sub tasks' do sub_tasks = 5.tim...
class Module def clone raise NotImplementedError , "Module#clone" end # Invoked as a callback when a reference to an undefined symbol is made. def const_missing(symbol) raise NameError, "uninitialized constant #{symbol}" end def include?(other) unless other._is_a?(Module) && ! other._is_a?(Cl...
require_relative "../repository" require_relative "../models/invoice" class InvoiceRepository < Repository def file_name "invoices.csv" end def model Invoice end def find_by_id(id) indices["id"][id].first end def find_all_by_customer_id(cust_id) indices["customer_id"][cust_id] end ...