text
stringlengths
10
2.61M
require 'rails_helper' describe 'Permissions' do let(:user) { FactoryBot.create(:user) } let(:user2) { FactoryBot.create(:user) } let(:admin_user) { FactoryBot.create(:user) } it 'allows admins to edit other users' do admin_user.admin = true admin_user.save sign_in(admin_user) visit edit_user_p...
require "test/unit" require "../app/models/trade/item" require "../app/models/trade/user" class ItemTest < Test::Unit::TestCase def test_create_item item = Item.new("book", 25) assert(item.name == "book") assert(item.price == 25) assert(item.state == :inactive) assert(item.owner.nil?) end d...
class AddFieldsToPlantings < ActiveRecord::Migration def change add_column :plantings, :planted_on, :date, after: :tree_id add_column :plantings, :event, :string add_column :plantings, :placement, :string add_column :plantings, :plant_space_width, :string add_column :plantings, :stakes_removed, :boolea...
class Error attr_accessor :id, :code, :message def initialize(params) @code = params[:code] @message = params[:message] end end
require 'test_helper' class UserTest < ActiveSupport::TestCase test "user must have username" do u = User.new assert !u.save, "Error" end test "user must have unique username" do u = User.new u.username = users(:userOne).username u.password = 'pass' u.password_confirmation = 'pass' ...
require 'spec_helper' class Person def self.ranks [:stranger, :classmate, :senpai, :osanajimi, :oniichan, :trevor] end # ranks attr_accessor :level, :rank @@ranks = { :stranger => 1, :classmate => 2, :senpai => 3, :osanajimi => 4, :oniichan => 5, :trevor => 6 } def initialize rank @level = @@rank...
module ProcurementValidator extend ActiveSupport::Concern # rubocop:disable Metrics/BlockLength included do # validations on :name step before_validation :remove_excess_whitespace_from_name, on: :name validates :name, presence: true, on: :name validates :name, uniqueness: { scope: :user }, on: :n...
FactoryBot.define do factory :history do postal_code { '111-1111' } prefecture_id { Faker::Number.between(from: 2, to: 48) } city { '横浜市緑区' } block { '青山1-1-1' } building_name { '柳ビル103' } phone_number { Faker::PhoneNumber.subscriber_number('00000000000') } token { 'tok_abcdefghijk00000000...
class SparklyController < (Auth.base_controller) helper_method :model_class, :model_instance, :model_name, :model, :model_path, :new_model_path, :edit_model_path, :model_config, :model_session_path, :model_params, :sparkly_config, :auth_config before_filter :find_user_model protected attr_acc...
class ListingsController < ApplicationController def index @listings = Listing.all.page(params[:page]) end def create @listing = Listing.create(listing_params) redirect_to @listing end def show @listing = Listing.find(params[:id]) end private def listing_params params.require(:li...
require 'test_helper' class ServiceListeners::AuthorNotifierTest < ActiveSupport::TestCase setup { ActionMailer::Base.deliveries.clear } test 'notifies users' do edition = create(:edition) creator = edition.creator second_author = create(:gds_editor) edition.authors << second_author ServiceLi...
require 'test_helper' class PostRoutesHelper < ActionController::TestCase context 'post routes' do should 'route to all posts' do assert_routing({method: 'get', path: URL_BASE + 'posts'}, {controller: URL_BASE + 'posts', action: 'index'}) end should 'route to create a post' do assert_routing({metho...
#!/usr/bin/env ruby #coding: UTF-8 system 'clear' require 'net/http' require 'colorize' # arg = {mode_name: uri} def download(arg) uri = URI(arg[:uri]) mode = arg.fetch(:mode,:full).to_s redirects_limit = arg[:redirects_limit] || 10 # опасная логика... Msg::info '' Msg::info "uri: #{uri}" Msg::info "mode...
class AddRecordLabelIdToArtists < ActiveRecord::Migration def change add_column :artists, :record_label_id, :string add_column :artists, :integer, :string end end
class SEDEQuery < ApplicationRecord belongs_to :offense_type has_many :review_results resourcify def fetch check_directory_structure resp = HTTParty.get url if resp.code == 200 File.open(File.join(Rails.root, "public/query_data/#{id}/latest.csv"), 'w:UTF-8') do |f| f.write(resp.body....
# frozen_string_literal: true # Advent of Code 2020 # # Robert Haines # # Public Domain require 'test_helper' require 'aoc2020/combo_breaker' class AOC2020::ComboBreakerTest < MiniTest::Test CARD_KEY = 5_764_801 DOOR_KEY = 17_807_724 ENCR_KEY = 14_897_079 def setup @cb = AOC2020::ComboBreaker.new end ...
class Api::V1::TagsController < Api::V1::BaseController before_action :offset_params, only: [:index] before_action :key_access before_action :authenticate, only: [:create, :destroy, :update] def show tag = Tag.find_by_id(params[:id]) if tag.nil? render json: { errors: "Couldn't find tag. Sure yo...
class Watchers::Reddit::Comment ATTRS = [:author, :subreddit, :permalink, :url, :body, :score, :id, :user_permalink] attr_accessor(*ATTRS) def self.parse(data) Watchers::Reddit::Comment.new(data['data']) end def initialize(data) @author = data['author'] @subreddit = data['subreddit'] @permal...
RSpec.describe "Dashboard", type: :system, js: true do context "With a new Diaper bank" do before :each do @new_organization = create(:organization) @user = create(:user, organization: @new_organization) @url_prefix = "/#{@new_organization.short_name}" end attr_reader :new_organization, ...
class TripReport < ApplicationRecord mount_uploader :photo, PhotoUploader belongs_to :climb belongs_to :user STATUS = ['IN', 'not IN', 'Sketchy', 'Status Unknown'] validates :date, :status, presence: true validates :content, length: { minimum: 20 } validate :date_cannot_be_in_the_past def date_canno...
# # Cookbook Name:: my-vagrant-development # Recipe:: default # # Copyright (C) 2014 Marcel Becker # # All rights reserved - Do Not Redistribute # include_recipe "apt" include_recipe "python" include_recipe "chef-solo-search" # To get vbox resolution to work correctly you need to re-install the vbgues # add a cd rom ...
# frozen_string_literal: true # @param {String} keyboard # @param {String} word # @return {Integer} def calculate_time(keyboard, word) prev_idx = 0 sum = 0 word.split('').each do |c| tmp_idx = keyboard.index(c) sum += (prev_idx - tmp_idx).abs prev_idx = tmp_idx end sum end
class CreateTaggings < ActiveRecord::Migration def change create_table :taggings do |t| t.integer :tag_id, foreign_key: true t.references :taggable, polymorphic: true, index: true t.timestamps null: false end add_index :tags, :label, unique: true add_index :taggings, [:tag_id, :tagg...
#!/usr/bin/env ruby require 'zlib' require 'open-uri' require 'optparse' require_relative "../lib/ml" Ml::Util.load_gem 'awesome_print', 'ap' # file, url, stringIO, etc... def default_readable_data_sets Dir["#{File.dirname(__FILE__)}/../fixtures/*"].reduce([]){|memo, f_path| memo << { :name => File.basename(f_...
require 'chef/config' require 'chef/log' require 'chef/resource/directory' require 'chef/provider' require 'chef/search/query' require_relative 'utils' class HdfsDirectoryError < RuntimeError; end class Chef class Provider::HdfsDirectory < Chef::Provider def whyrun_supported? true end def load...
=begin However, variable assignment still returns the value it was assigned to. It works the same as if the assignment wasn't even there. Since we know that the else clause was ignored, we can safely determine that the return value will be 1 because it's the only evaluated value in the if clause. end
class Notification < ActionMailer::Base def new_account(user, sent_at = Time.now) subject 'Welcome to Nanoblog' recipients user.email from 'nanoblog@nanoblog.com' sent_on sent_at content_type 'text/html' body :user => user end end
class Store < ApplicationModel has_many :posts, :dependent => :nullify has_many :activities has_many :store_foods, :dependent => :destroy has_one :attach_file has_many :likes, :conditions => {:object => "Store"}, :foreign_key => "foreign_key" has_many :bookmarks, :conditions => {:object => "Store"}, :foreig...
# frozen_string_literal: true # encoding: UTF-8 require_relative 'test_helper' class SillyEncryptor def self.silly_encrypt(options) (options[:value] + options[:some_arg]).reverse end def self.silly_decrypt(options) options[:value].reverse.gsub(/#{options[:some_arg]}$/, '') end end class User exten...
class User < ActiveRecord::Base belongs_to :primary_email, :class_name => 'EmailAddress' has_many :email_addresses, :class_name => 'EmailAddress' belongs_to :permission belongs_to :visibility, :class_name => 'UserVisibility' has_many :community_members, :dependent => :destroy has_many :communities, :throu...
class User < ApplicationRecord devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable has_many :todo_lists has_many :todos has_many :comments enum status: [:qualified, :not_qualified, :banned] validates :username, :email, :type, presence: true validates :status...
# frozen_string_literal: true module GraphQL module StaticValidation module FragmentsAreNamed def on_fragment_definition(node, _parent) if node.name.nil? add_error(GraphQL::StaticValidation::FragmentsAreNamedError.new( "Fragment definition has no name", nodes: node ...
require "spec_helper" RSpec.describe "Day 16: Proboscidea Volcanium" do let(:runner) { Runner.new("2022/16") } let(:input) do <<~TXT Valve AA has flow rate=0; tunnels lead to valves DD, II, BB Valve BB has flow rate=13; tunnels lead to valves CC, AA Valve CC has flow rate=2; tunnels lead to v...
class Student < ActiveRecord::Base after_initialize :init validates_presence_of :name,:student_class,:marks,:description validates :name,format: {with:/\A[a-zA-Z]+\z/, message: "only allows letters"} validates :name,:length => {:minimum =>3,:maximum => 500,:too_short => "name is too short,%{count} is allowed"...
describe UserController do let!(:user) {User.create!(first_name: "Alex", last_name: "Hill", username: "alexhill", email: "alex@hill.com", password: "password")} describe "GET#login" do it "responds with status code 200" do get :login expect(response).to have_http_status end end it "rend...
require 'spec_helper' describe App do it "accepts a settings field in its parameter hash" do App.new({"app_name" => 'My cool app'}) end describe "Given no app, a new default app" do before :each do @app = App.new end it "should be valid after filling the title" do @app.app_name = "s...
# coding: utf-8 class DivisionsController < ApplicationController before_filter :find_division, :only => 'show_workers' def index @divisions = Division.order(:id) end def show_workers @workers = Worker.select([:lastname, :firstname, :soname, :staffname]).where('code_division like ?', params[:division_c...
# rubocop:disable Lint/RescueException def guard_call(bridge_name, &block) block.call rescue Exception => e error bridge_name, "Exception for thread ##{bridge_name}, got:" error bridge_name, "\t#{e.message}" error bridge_name, "\t#{e.backtrace.join("\n\t")}" end # rubocop:enable Lint/RescueException def in_gro...
class CreatePesticides < ActiveRecord::Migration def change create_table :pesticides do |t| t.string :TradeName t.string :EpaNumber t.string :ActiveIngredient t.string :Manufacturer t.timestamps null: false end end end
require 'spec_helper' describe "Character pages" do subject { page } describe "profileCharacter page" do let(:character) { FactoryGirl.create(:character) } before { visit character_path(character) } it { should have_content(character.name) } it { should have_title(character.name) } end desc...
class RemoveNullConstraintForStandardFrameworkIdFromStandards < ActiveRecord::Migration def change change_column_null :standards, :standard_framework_id, true end end
class CommentsController < ApplicationController ## Create new comments def create @post = Post.find(params[:post_id]) @comment = @post.comments.create(comment_params) redirect_to post_path(@post) end #edit comment def edit @post = Post.find(params[:post_id]) @comment = @post.comments.find(params[:id]) ...
class AttributeOptionsController < ApplicationController include Response def index # if params[:query].present? && params[:field].present? # @attribute_options = @attribute_options.where("LOWER(#{params[:field]}::VARCHAR) like ?", '%'+params[:query].to_s.downcase+'%') # end # # if params[:ch...
class RemoveChoreFieldsFromPartnerService < ActiveRecord::Migration[5.0] def change remove_column :partner_services, :mobile, :string remove_column :partner_services, :facebook, :string end end
=begin #Rakam API Documentation #An analytics platform API that lets you create your own analytics services. OpenAPI spec version: 0.5 Contact: contact@rakam.io Generated by: https://github.com/swagger-api/swagger-codegen.git Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file e...
require 'salt/host' module Salt class Minion < Host # attr_accessor :master def initialize(name, info) self['minion_config'] = {} super end def pub_key File.join(@keypath, "#{@name}.pub") end def pem_key File.join(@keypath, "/#{@name}.pem") end ...
class UserMailer < MandrillMailer::TemplateMailer default from: 'marketing@nursegridreferral.com' def referral_confirmation(user) mandrill_mail template: 'referral-program-point-confirmation', subject: 'A friend has just used your referral code!', to: user.email, ...
class Application < Rhoconnect::Base class << self def authenticate(username,password,session) svc="http://rhomobile.5pmweb.com/api/dev/wsdl/authentication.wsdl" client = Savon.client(svc) response=client.request :sign_in do soap.body={:login=>username,:password=>password} en...
class Region < ActiveRecord::Base has_many :stores attr_encrypted :leader_name, :key => ENV['ENCRYPTION_KEY'] def label "#{self.name} (#{self.leader_name})" end def percentage_complete ((stores.has_submission.count.to_f / stores.count) * 100).round(2) end end
class AddEmailToMangements < ActiveRecord::Migration[5.0] def change add_column :mangements, :email, :string, :unique => true end end
module MDB class Role < ActiveRecord::Base attr_accessible :parent, :users, :title, :symbol belongs_to :parent, :class_name => "MDB::Role" has_many :children, :class_name => "MDB::Role", :foreign_key => "parent_id" has_many :users validates_presence_of :title # Generate nic...
# Attributes # _id => auto generated user id # dn => distinguished user name from certificate # login => last CN attribute value from dn class ScalarmUser < MongoActiveRecord def self.collection_name 'scalarm_users' end def get_running_experiments DataFarmingExperiment.find_all_by_user_id(self.id).sele...
class AddTypeTripToTripsToUser < ActiveRecord::Migration def change add_column :trips_to_users, :type_of_trip, :string, :default => "guide" end end
When /^I try to search events with "(.*?)","(.*?)" and "(.*?)"$/ do |location, start_date, end_date| execute_script("$('#location').val('#{location}')") execute_script("$('#start_date').val('#{start_date}')") execute_script("$('#end_date').val('#{end_date}')") find_button('Submit').trigger('click') end Then /^...
#!/usr/bin/env ruby # vim: et ts=2 sw=2 require "icloud" module ICloud module Reminders # # This class is a thin wrapper around ruby-icloud, to be called by the CLI. # It mostly exists just to be stubbed out. # class Driver def initialize(username, password) @session ||= ICloud::S...
#!/usr/bin/env ruby require File.join(File.dirname(__FILE__), "..", "spec_helper") describe "Textile Markup" do before do @textile = %{This is a _test_: * item A * item B * item C <div class="test">_hello!_ </div> Testing: # A # B # C} @html = %{<p>This is a <em>test</em>:</p> <ul> <li>item A</li> <li>item ...
class CreateYelpBusinesses < ActiveRecord::Migration def change create_table :yelp_businesses do |t| t.string :name t.string :address t.string :city t.string :state t.float :yelp_rating t.integer :yelp_review_count t.timestamps end end end
ActionController::Routing::Routes.draw do |map| map.connect '', :controller => "module" map.connect '/author/:action', :controller => "author" map.connect '/module/:action', :controller => "module" map.connect '/license/:action', :controller => "license" map.connect '/admin/:action', :controller => "admin" ...
require 'zip/zip' require 'forwardable' module Swathe class Zip < Archive attr_accessor :zip_reader include Enumerable def initialize(io) @zip_reader = ::Zip::ZipFile.open(io) end def self.open(file_name) new(file_name) end def zip? true end def each(*args, &...
class ServicesController < ApplicationController # new, create, show, edit, update, destroy def index @services = Service.all end def new @service = Service.new end def create service_params = params.require(:service).permit(:name, :price, :duration, :description) # Hash = {name: "Serviço ...
class Graph def initialize(nv, edges) @nvertices = nv @adjlist = nv.times.collect { [] } edges.each do |i, j, w| @adjlist[i] << [j, w] end end def each_vertices @nvertices.times do |i| yield i end end def each_edges @nve...
require 'i18n' include I18n module NumberToWord def self.t(obj) I18n.t(obj) end UNDER_HUNDRED = {""=>"", 0=>t('zero'), 1=>t('one'), 2=>t('two'), 3=>t('three'), 4=>t('four'), 5=>t('five'), 6=>t('six'), 7=>t('seven'), 8=>t('eight'), 9=>t('nine'), 10=>t('ten'), 11=>t('eleven'), 12=>t('twelve'), 13=>t...
require 'spec_helper' describe Sub do context 'without user_id or title' do let(:incomplete_sub) { sub1 = Sub.new } it "validates presence of title" do expect(incomplete_sub).to have(1).error_on(:title) end it "validates presence of user_id" do expect(incomplete_sub).to have(1).error_on...
require File.dirname(__FILE__) + '/../spec_helper' describe Message do it "should validate that the user is a player in a game" do game = Factory(:game) Factory.build(:message, :game => game, :user => game.black_player).should be_valid Factory.build(:message, :game => game, :user => Factory(:user)).shoul...
require 'capybara/rspec' require 'airport' require 'plane' ## Note these are just some guidelines! ## Feel free to write more tests!! # Given 6 planes, each plane must land. # Be careful of the weather, it could be stormy! # Check when all the planes have landed that they have status "landed" # Once all planes are in...
class ReportMailer < ApplicationMailer default from: 'no-reply@refundclerk.herokuapp.com', to: Proc.new { User.where(admin: true).pluck(:email) } def report_email(month, year, report) @report_records = report @month = month @year = year mail(from: 'no-reply@refundclerk.herokuapp.com', ...
json.array!(@asientos) do |asiento| json.extract! asiento, :id, :numero, :posicionX, :posicionY json.url asiento_url(asiento, format: :json) end
class Lorem < Formula desc "Python generator for the console" homepage "https://github.com/per9000/lorem" revision 1 head "https://github.com/per9000/lorem.git" stable do url "https://github.com/per9000/lorem/archive/v0.7.4.tar.gz" sha256 "7917f4b8ead5209ddb44c395955dcc276ea63a81d8a416b5d0a5ef8f545b...
class AChaozhi < ActiveRecord::Base # attr_accessible :title, :body validates_presence_of :a_product_id, :message=>"选择商品" belongs_to :product, :class_name=>"AProduct", :foreign_key=>"a_product_id" def is_current if self.begin_at < Time.new && self.stop_at > Time.new true else false end ...
#encoding: utf-8 Gem::Specification.new do |s| s.name = 'igs_bar_chart' s.version = '0.0.1' s.required_ruby_version = '>= 1.9.1' s.date = Date.today s.summary = "Bar Chart is a gem for creating bar charts (duh!)." s.description = "#{s.summary} It uses D3 (Data Driven Documents) to aggr...
class UserSerializer include FastJsonapi::ObjectSerializer attributes :id, :username attribute :avatar_url do |user| Rails.application.routes.url_helpers.rails_blob_path(user.avatar) if user.avatar.attached? end attribute :rooms do |user| user.rooms.uniq end end
class ConsortsController < ApplicationController # GET /consorts # GET /consorts.xml def index @consorts = Consort.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @consorts } end end # GET /consorts/1 # GET /consorts/1.xml def show @consor...
# U3.W8-9: Reverse Words # I worked on this challenge [by myself]. # 2. Pseudocode # 3. Initial Solution =begin def reverse_words(sentence) sentence.reverse end =end # 4. Refactored Solution def reverse_words(sentence) sentence.split(' ').map {|word| word.reverse}.join(' ') end # 1. DRIVER TESTS/ASSERT STATE...
class CreateUserMileages < ActiveRecord::Migration def self.up create_table :user_mileages do |t| t.integer :user_id, :null => false t.integer :total_point, :default => 0 t.string :grade t.boolean :special_user t.boolean :blacklist_user t.timestamps end end def self.d...
# Part C require("Minitest/autorun") require("minitest/rg") require_relative("../library") class TestLibrary < MiniTest::Test def setup @book1 = { title: "lord_of_the_rings", rental_details: { student_name: "Jeff", date: "01/12/16" } } @book2 = { ...
class AddPilotMetricToEmployee < ActiveRecord::Migration def change remove_column :interactions, :task add_column :interactions, :pilot_metric, :boolean end end
require 'spec_helper' describe Startup do let(:new_startup) { FactoryGirl.create(:startup) } context 'Validation' do it 'fails without a name' do startup = FactoryGirl.build(:startup, name: '') expect(startup).not_to be_valid expect(startup).to have(1).error_on(:name) end it 'fails...
class Autor attr_reader :name attr_reader :geburtstag def initialize(name, geburtstag) @name = name @geburtstag = geburtstag end end
## # Section describes a heirarchical categorization. All Stories are intended to be filed under # a singular section. # # @!attribute title # @return [String] the main name of the section, limited to 75 chars # @!attribute description # @return [Text] description of the section, limited to 140 chars class Sect...
require 'test_helper' class QuestionsControllerTest < ActionController::TestCase test "should get index" do get :index assert_response :ok assert_select "a[href=#{new_question_path}]" assert_select "#questions article.question", Question.count end test "should get unanswered" do get :unanswe...
class User attr_reader :name def initialize(name:) @name = name.strip end def save is_valid? end private def is_valid? !name.empty? && name.size < 40 end end
# frozen_string_literal: true class Product < ApplicationRecord has_many :sold_products belongs_to :category validates :name, presence: true # paginates_per 10 # Set the pagination items per page has_one_attached :image def resize image.variant(resize_to_limit: [100, 100]) end end
module RegistrationDecorator def label name end def starting_at_weekday I18n.translate(starting_at.wday, scope: %i[map weekdays]) end end
# frozen_string_literal: true require 'test_helper' # rubocop:disable Metrics/BlockLength describe FeedsController do let(:user) { users :test1 } let(:feed) { user.subscriptions.first.feed } before do login user end it 'should get index' do get :index assert_response :success assert_not_ni...
class Message < ActiveRecord::Base attr_accessible :content, :receiver_id, :sender_id belongs_to :receiver, class_name: "User" belongs_to :sender, class_name: "User" has_many :notifications, as: :notifiable end
require 'rails_helper' feature 'Top page' do # 公開すべき妥当なスライダーデータを表示する scenario "show slider data" do slider1 = create(:slider, title: "test1", aasm_state: "active") slider2 = create(:slider, title: "test2", aasm_state: "active") slider3 = create(:slider, title: "test3", aasm_state: "active") slider4...
# frozen_string_literal: true RSpec.describe Hanamimastery::CLI::Transformations::ToPRO do let(:content) do <<~STRING paragraph 1 paragraph 2 # Level 1 header # Level 2 Header # Level 3 Header ![Sample Image](/images/episodes/34/sample-image.png) :::call to action 1 ...
class Artist < ActiveRecord::Base has_many :songs has_many :genres, through: :songs def slug self.name.downcase.gsub(" ", "-") end def self.find_by_slug(slug) name = slug.gsub("-", " ") self.all.find do |song| song.name.downcase == name end end end
# frozen_string_literal: true module TugoCommon module ErrorHandler class InvalidRequestParamsHandler < ErrorHandler::BaseHandler def run! @exception.errors.messages.each do |field, messages| messages.each do |message| add_custom_field_error(field, message) end ...
require "./lib/Lesson 3 Time Complexity/TapeEquilibrium/tape_equilibrium" describe 'TapeEquilibrium' do describe 'Example Tests' do it 'example: [3, 1, 2, 4, 3] to 1' do expect(tape_equilibrium([3, 1, 2, 4, 3])).to eq 1 end end describe 'Correctness Tests' do context 'double - two ...
class CreateForklifts < ActiveRecord::Migration[5.1] def change create_table :forklifts do |t| t.string :plate t.integer :brand t.integer :lifting_capacity t.integer :production_year t.integer :lifting_height t.integer :type t.integer :price t.string :model t....
###--------------------------------------------------------------------------### # Scale Encounters script # # Version 1.0 # # ...
require_relative "age/version" module Unicode module Age class UnknownAge < StandardError; end KNOWN_UNICODE_VERSIONS = [ 1.1, 2.0, 2.1, 3.0, 3.1, 3.2, 4.0, 4.1, 5.0, 5.1, 5.2, 6.0, 6.1, 6.2, 6.3, 7.0, 8.0,...
class AddAccessTokenToProject < ActiveRecord::Migration[6.0] def change add_column :projects, :encrypted_access_token, :string, null: false add_column :projects, :encrypted_access_token_iv, :string, null: false end end
require "json" require_relative "./compute" describe "Compute" do it "output and expected output for level 1 should be identicals" do output = compute("./level1/data/input.json") expected_output = JSON.parse(File.read("./level1/data/expected_output.json")) expect(output).to eq(expected_outp...
require 'spec_helper' describe SessionsController do describe "routing" do it "routes to #new" do expect(get("/login")).to route_to("sessions#new") end it "routes to #create" do expect(post("/session")).to route_to("sessions#create") end it "routes to #destory" do expect(get("...
require 'assert' require 'sanford/cli' class Sanford::Manager::PIDFile class BaseTests < Assert::Context desc "Sanford::Manager::PIDFile" setup do @pid_file_path = File.join(ROOT, "tmp/my.pid") @pid_file = Sanford::Manager::PIDFile.new(@pid_file_path) end teardown do FileUtils.rm_r...
require "spec_helper" describe Swow::Fields do describe "initialize" do context "field is an array" do let(:fields) { [1, 2, 3] } it "set fields" do expect(Swow::Fields.new(fields, []).to_a).to eq(fields) end end context "field is not an array" do let(:fields) { "a" } ...
class Article < ApplicationRecord belongs_to :user has_many :likes, dependent: :destroy # has_one_attached :image has_many :article_tag_relations has_many :tags, through: :article_tag_relations, dependent: :destroy end
require 'json' ## # JSON helper to include virtual attributes from an object. The result JSON is always a map. # # Virtual attributes can be specified using +json_virtual_attributes+ in a following manner: # # class MyClass # attr_accessor :att1, :att2 # json_virtual_attribute :virtual1, :virtual2 # ...