text stringlengths 10 2.61M |
|---|
require 'rails_helper'
RSpec.describe User, type: :model do
before do
@user = FactoryBot.create(:user)
end
describe "creation" do
it "can be created" do
expect(@user).to be_valid
end
it "can not be created without a username" do
@user.username = nil
expect(@user).to_not be_valid
en... |
module Milksteak
class Page < YmlContent
attr_accessor :route
def self.folder; "pages"; end
# override write to include validation for :route. If validation
# becomes something that is needed on a bigger scale, we'll need
# to put this into another method activerecord-style
def sel... |
class AdminController < ApplicationController
layout 'admin'
before_filter :jquery_noconflict
before_filter :basic_auth
def jquery_noconflict
ActionView::Helpers::PrototypeHelper.const_set(:JQUERY_VAR, 'jQuery')
end
private
def basic_auth
authenticate_or_request_with_http_basic do |id, passw... |
class ChangeProcessNumberTypeInCostCenterDetails < ActiveRecord::Migration
def change
change_column :cost_center_details, :process_number, :string
change_column :cost_center_details, :contract_number, :string
end
end
|
class User < ApplicationRecord
rolify
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :transfers
belongs_to :country, opt... |
class Family
include Relix
relix do
primary_key :key
end
attr_reader :key
def initialize(key)
@key = key
index!
end
def delete
deindex!
end
end
class Person
include Relix
relix do
primary_key :key
multi :family_key, order: :birthyear, index_values: true
unique :by_birth... |
class FacebookController < ApplicationController
skip_before_filter :verify_authenticity_token
after_filter :allow_iframe, :only => [:index, :setup_page, :fb_sign_in, :setup]
layout 'facebook'
def index
if request.get?
restaurant = Restaurant.where(preview_token:"_1cBOnm8VulZNOxzezNiPw").fi... |
require_relative 'csv_record'
module RideShare
class Driver < CsvRecord
attr_reader :id, :name, :vin, :trips
attr_accessor :status
def initialize(id:, name:, vin:, status: :AVAILABLE, trips: [])
super(id)
@name = name
@vin = vin
raise ArgumentError.new("Invalid VIN") if (vin.len... |
require 'test/unit'
require 'noofakku/instruction/brackets'
require 'shoulda'
require 'ostruct'
module Noofakku
class BracketsTest < Test::Unit::TestCase
context "Execution" do
setup do
@instance = Brackets.new('[', ']')
end
should "throw on nil processor" do
assert_raise (R... |
class RenameNameToLastNameInStudents < ActiveRecord::Migration
def change
rename_column(:students, :name, :last_name)
end
end
|
require "test_helper"
class CourseMailerTest < ActionMailer::TestCase
# called before every single test
setup do
@user = users(:mary)
@course = courses(:patin_beginners)
end
test "new_published_course" do
# Create the email and store it for further assertions
travel_to Date.new(2017, 9, 2) do
... |
class AddMeterNumberToMeter < ActiveRecord::Migration
def change
add_column :meters, :meter_number, :string
add_column :meters, :people_in_house, :integer
end
end
|
class User < ApplicationRecord
validates :name, presence: true
validates :email, presence: true
has_many :sent_tweets, class_name: "Tweet", foreign_key: "author_id"
has_and_belongs_to_many :received_tweets, class_name: "Tweet"
has_many :tweet_likers, class_name: "Tweet", foreign_key: "liker_id"
has_and_b... |
class Habilitacao < ApplicationRecord
belongs_to :pessoa
validates :numero, :modalidades, :validade, presence: true
end |
class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!
before_action :verify_user, except: [:index]
respond_to :html
def index
@users = User.all
respond_with(@users)
end
def show
respond_with(@user)
... |
class ShopCategory < ActiveRecord::Base
belongs_to :shop
belongs_to :category
attr_accessible :shop, :category
end
|
class UserSerializer
include FastJsonapi::ObjectSerializer
attributes :github_username, :github_repo_path, :github_repo_url, :twitter_username, :email
attribute :github_linked do |object|
!!object.encrypted_github_token
end
attribute :twitter_linked do |object|
!!object.encrypted_twitter_token
end... |
# install and setup hadoop
tar_name = "hadoop-#{node['hadoop']['version']}"
remote_file "#{Chef::Config['file_cache_path']}/#{tar_name}.tar.gz" do
source "http://archive.cloudera.com/cdh/3/#{tar_name}.tar.gz"
checksum node['hadoop']['checksum']
# notifies :run, 'bash[install_tmux]', :immediately
end
hadoop_paren... |
class CartesianProduct
include Enumerable
def initialize(seq1,seq2)
@seq1= seq1
@seq2= seq2
end
def each
seq = @seq1.product(@seq2)
seq.each{ |x| yield x }
end
end
|
# A Nested Array to Model a Bingo Board SOLO CHALLENGE
# I spent [4] hours on this challenge.
# Release 0: Pseudocode
# DEFINE class BingoBoard
# DEFINE initialize method which takes a default board as its argument
# CREATE intance variables @board and @letters to be used later in the program
# END
# D... |
require File.join(Dir.pwd, 'spec', 'spec_helper')
describe 'RoleList' do
before do
simulate_connection_to_server
end
after do
end
it 'should pass if role list attribute is not specifed' do
request_data = FactoryGirl.attributes_for(:role_list).to_json
TheCityAdmin.stub(:admin_request).and_ret... |
require_relative "../models/dog"
describe Dog do
subject(:dog) { Dog.new(:name) }
before do
dog.name = "Fido"
dog.hungriness = 5
end
describe "::new" do
it "initializes a new dog" do
expect(dog).to be_a(Dog)
end
end
describe "#name" do
it "allows the reading and writing of a name" do
... |
class AddUserImage < ActiveRecord::Migration
def change
add_attachment :preferences, :image
end
end
|
class UsersController < ApplicationController
before_filter :authenticate_user!
def show
@user = !params[:id].nil? ? User.find(params[:id]) : current_user
authorize @user
end
end
|
Given(/^I, (\w+) (\w+), am a user$/) do |first_name, last_name|
@user = create(:user, first_name: first_name, last_name: last_name)
end
When(/^I fill out the login form with user info$/) do
fill_in "user[email]", with: @user.email
fill_in "user[password]", with: @user.password
click_on "Log in"
end
When(/^I f... |
module Jekyll
module RegexFilter
def replace_regex(input, reg_str, repl_str)
re = Regexp.new reg_str, Regexp::MULTILINE
# This will be returned
input.gsub re, repl_str
end
end
end
Liquid::Template.register_filter(Jekyll::RegexFilter)
#######
# This function rewrites a link in the follo... |
class User < ActiveRecord::Base
validates :first_name, presence: true
validates :last_name, presence: true
validates :email, presence: true
has_many :restaurants
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticata... |
require 'spec_helper'
describe Paperclip::DocsplitPdf do
def make_output
Paperclip::DocsplitPdf.new(@file).make
end
context "with a Microsoft Word .docx file" do
before(:all) do
@file = File.open("./fixtures/word_xml.docx")
@output = make_output
end
after(:all) do
@file.close
... |
require 'rails_helper'
RSpec.describe User, type: :model do
it {should validate_presence_of(:email)}
it {should validate_uniqueness_of(:email)}
it {should validate_presence_of(:name)}
it {should validate_presence_of(:password)}
it {should have_secure_password}
describe "instance methods" do
it 'can ge... |
class ContactQuery < Types::BaseResolver
description "Gets the specified contact"
argument :id, ID, required: true
type Outputs::ContactType, null: true
policy ContactPolicy, :view?
def resolve
Contact.find(input.id).tap { |contact| authorize contact }
end
end
|
class ContentTypeValidator < ActiveModel::EachValidator
#enables file type validations for active record
def validate_each(record, attribute, value)
return unless value.attached?
return if value.content_type.in?(content_types)
value.purge
record.errors.add(attribute, :content_type, options)
end
... |
#encoding: utf-8
require_relative 'BadConsequence.rb'
module Model
class BadConsequenceNumbers < BadConsequence
def initialize(text, levels, nVisible, nHidden)
super(text,levels, nVisible, nHidden, false, Array.new, Array.new)
end
def isEmpty
if(@levels == 0 && @nVisibleTreasures == 0 && @nHiddenTreasures == 0... |
class Condition < ApplicationRecord
validates_presence_of :date
validates_presence_of :max_temperature_f
validates_presence_of :mean_temperature_f
validates_presence_of :min_temperature_f
validates_presence_of :mean_humidity
validates_presence_of :mean_visibility_miles
validates_presence_of :mean_wind_spe... |
ActiveRecord::Schema.define(:version => 0) do
create_table :message_thread_models, :force => true do |t|
t.string :subject
t.datetime :created_at
t.datetime :updated_at
end
create_table :message_models, :force => true do |t|
t.integer :sender_id
t.integer :thread_id
t.boolean :sen... |
#!/usr/bin/env ruby
@pom = File.open('./pom.xml')
def pom_version
require 'nokogiri'
doc = Nokogiri::XML(@pom)
doc.xpath('/x:project/x:version', 'x' => 'http://maven.apache.org/POM/4.0.0')[0].content
end
def sign
@artifacts.each do |file|
%x{ gpg2 -ab target/#{file} }
end
exit 1 if ($?.exitstatus !=... |
#!/usr/bin/env ruby1.9.1
require 'cinch'
require 'chronic'
###############################################################################
class AutoHello
include Cinch::Plugin
listen_to :join
def listen(m)
unless m.user.nick.end_with?("-bot")
m.reply "hi #{m.user.nick}"
end
end
end
##########... |
class CreateExercisesPerformeds < ActiveRecord::Migration
def change
create_table :exercises_performeds do |t|
t.integer :exercise_type_id
t.decimal :calories_burned, precision: 6, scale: 2
t.date :date_burned
t.timestamps null: false
end
end
end
|
class CreateCancelaciones < ActiveRecord::Migration
def change
create_table :cancelaciones do |t|
t.references :partida_contable, :null => false
t.datetime :fecha_de_ingreso, :null => false
t.references :medio_de_pago, :null => false
t.integer :importe_cents, :null => false
t.string ... |
require 'rails_helper'
RSpec.describe Comment, type: :model do
it { is_expected.to have_attribute :body }
it { is_expected.to have_attribute :link_id }
it { is_expected.to belong_to :link }
it { is_expected.to validate_presence_of :body }
end
|
class DeliveriesController < ApplicationController
before_action :set_delivery, only: [:show, :edit, :update, :nav, :pickup]
def create
@delivery = Delivery.new
@delivery.user_id = current_user.id
@delivery.request_id = params[:request_id]
@delivery.accepted!
@delivery.request.accepted!
aut... |
class Subpool < ActiveRecord::Base
# attr_accessible :title, :body
has_many :subpool_players, dependent: :destroy
has_many :players, :through => :subpool_players
belongs_to :creator, class_name: 'Player', foreign_key: :creator_id
validates_uniqueness_of :name
validates_presence_of :name, :creator_id
de... |
class Spinach::Features::AdminDeployKeys < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
include SharedAdmin
step 'there are public deploy keys in system' do
create(:deploy_key, public: true)
create(:another_deploy_key, public: true)
end
step 'I should see all public deplo... |
require "rails_helper"
current_date = Date.today
RSpec.describe Reports::PatientState, {type: :model, reporting_spec: true} do
describe "Associations" do
it { should belong_to(:patient) }
end
around do |example|
freeze_time_for_reporting_specs(example)
end
it "does not include deleted patients" do... |
class SessionsController < ApplicationController
skip_before_action :require_login, only: [:create]
def create
auth_hash = request.env['omniauth.auth']
# Should probably use the nickname and email fields as well
user = User.find_by(uid: auth_hash["uid"], provider: auth_hash["provider"])
# if its... |
require 'spec_helper'
describe Opendata::License, dbscope: :example do
context "check attributes with typical url resource" do
let(:site) { cms_site }
let(:license_logo_file_path) { Rails.root.join("spec", "fixtures", "ss", "logo.png") }
let(:license_logo_file) { Fs::UploadedFile.create_from_file(license... |
require_relative "pond"
require_relative "frog"
class FrogPond < Pond
def new_animal(name)
Frog.new(name)
end
end
pond = FrogPond.new(3)
pond.simulate_one_day
|
# == Schema Information
#
# Table name: videos
#
# id :integer not null, primary key
# title :string
# youtube_link :string
# sort_order :integer
# created_at :datetime
# updated_at :datetime
# thumbnail :string
#
class Video < ActiveRecord::Base
validates :youtube_link, :sor... |
class Card
SUITS = %w(h d c s).freeze
DECK_VALUES = %w(A 2 3 4 5 6 7 8 9 10 J Q K).freeze
def initialize(suit, value)
@suit = suit
@value = value
end
def to_s
"[#{@value}#{@suit}]"
end
def value
case @value
when 'J' then 'J'
when 'Q' then 'Q'
when 'K' then 'K'
when 'A' t... |
class Beer < ActiveRecord::Base
belongs_to :brewery
has_many :ratings, :dependent => :destroy
include RatingsAverage
def to_s
name + ' (' + brewery.name + ')'
end
end
|
name 'hubrel'
maintainer 'Robert Veznaver'
maintainer_email 'rv@bidmotion.com'
license 'Apache 2.0'
description 'hubrel library cookbook'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.2.0'
issues_url 'https://github.com/Hydrane/hubrel/... |
class FakeView
attr_reader :calls
def initialize
@calls = []
end
def datetime_formatter(time)
time.strftime("%d %B %Y %H:%M")
end
def method_missing(method, *args)
@calls << [method, *args]
yield if block_given?
"#{method} #{args.inspect}"
end
end
|
class Address < ApplicationRecord
belongs_to :user, optional: true
validates :zipcode, :prefecture, :city, :district, :building, presence: true
end
|
# frozen_string_literal: true
class Favorite < ::ApplicationRecord
def table_id = 'fav'
belongs_to :favorable, polymorphic: true
belongs_to :user
class << self
def register(favorites, user)
::ActiveRecord::Base.transaction do
favorites.each { |favorite| find_or_create_by(favorable: favorite... |
class Tag < ActiveRecord::Base
has_many :articles, through: :relations
has_many :relations
def self.create_by_name(name)
optional_tag = find_by(name: name)
if optional_tag
optional_tag
else
new(name: name).tap do |tag|
tag.save
end
end
end
end
|
# frozen_string_literal: true
module Simulation
autoload :Batch, 'simulation/batch'
autoload :BatchOptions, 'simulation/batch_options'
autoload :BulkSimulation, 'simulation/bulk_simulation'
autoload :Infected, 'simulation/infected'
autoload :Iterator, 'simulation/iterator'
autoload :... |
# 2. Dog# initialize with Name and Breed defaulting to "Mutt"
# Define a Dog class in lib/dog.rb that provides an #initialize
# method that accepts an argument for the dog's name. That argument
# should be stored within a @name instance variable.
# Additionally, Dog#initialize should accept a second optional argum... |
class Api::V1::DealersController < ApplicationController
# TODO: Add authroization for only internal users with permissions to trigger this endpoint
# There is a rake task that does the same job
def add_point_of_sales_dealers
AddDealersWorker.perform_async
# TODO: Make the message part of the I18n of the... |
require 'test_helper'
require 'source/shows'
class SearchingSourceShowsTest < ActionDispatch::IntegrationTest
teardown do
Source::ShowsGateway.any_instance.unstub(:search)
end
test 'status' do
stub_source_result gateway_search_result
get '/source_shows', { query: 'chips dub' }, request_headers
... |
require 'pathname'
require 'logger'
require 'set'
require 'erb'
# Required elements of rubygems
require "rubygems/remote_fetcher"
require "rubygems/installer"
require "bundler/gem_bundle"
require "bundler/source"
require "bundler/finder"
require "bundler/gem_ext"
require "bundler/resolver"
require "bundle... |
describe Cheque::Copy do
subject(:copy) { described_class.new(params) }
let(:params) do
{
id: 1,
title: 'Payment',
bank: 'Global Banking',
agency_number: '123',
account_number: '456',
cheque_number: '789',
account_holder: 'Jimmy Hendrix Group',
nominal_to: 'Ferna... |
class Photo < ActiveRecord::Base
belongs_to :user
has_attached_file :photo
validates_presence_of :user
validates_attachment_presence :photo
validates_attachment_size :photo, :less_than => 1.megabytes
validates_attachment_content_type :photo, :content_type => ['image/jpeg', 'image/jpg', 'image/png']
... |
# frozen_string_literal: true
# Keppler
module Downloadable
extend ActiveSupport::Concern
included do
require 'csv'
def self.to_csv(options = {})
CSV.generate(options) do |csv|
csv << column_names
all.each { |object| csv << object.attributes.values }
end
end
end
end
|
require 'rails_helper'
RSpec.feature "Creating tournaments" do
before do
visit "/"
end
scenario "log in" do
click_link "Get Started!"
fill_in "Email", with: "test@test.no"
fill_in "Password", with: "abc12345"
fill_in "Password confirmation", with: "abc12345"
fill_in "First name", with: "... |
require 'state_mvc/input_delegate_base'
# controller is a MapEditorGuiController
class MapEditorInputDelegate < State::InputDelegateBase
def init
super
@control_map = Game.instance.database['controlmaps/map_editor']
end
def control_map_to_keymap(map, commands)
commands.each_with_object({}) do |comma... |
class Post
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Slug
include Content
include PostFiles
slug :title, history: true
field :url, type: String
end
|
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :authenticate_user!
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up) { |u| u.perm... |
module Checker
def full?
if @capacity.size >= total_capacity.to_i
true
else
false
end
end
def add(item)
unless full?
@capacity << item
else
raise "This is currently at full capacity."
end
@capacity.length
end
def remove_item
@capacity.pop
end
def... |
# Numbers to English Words
# I worked on this challenge by myself.
# This challenge took me [] hours.
# Pseudocode
#
# Input: an integer >= 100
#
# Output: it's name in the english language
#
# Pseudocode:
# -Create a library of strings for numbers
# -create a new array to be filled with strings and returned
# -Spl... |
require_relative "test_helper"
require_relative '../lib/user'
describe "#initialize" do
it "returns a specific instance of a User" do
user = nil
VCR.use_cassette("chat.postMessage") do
data = {'id' => '1234',
'name' => 'bot',
'real_name' => 'testbot',
'profile' => {'status_text'... |
class Code
POSSIBLE_PEGS = {
"R" => :red,
"G" => :green,
"B" => :blue,
"Y" => :yellow
}
attr_reader :pegs
def self.valid_pegs?(char_arr)
char_arr.all? { |char| POSSIBLE_PEGS.include?(char.upcase) }
end
def initialize(char_arr)
if !Code.valid_pegs?(char_arr)
raise "ERROR: Not... |
# frozen_string_literal: true
# regex_replace.rb
# Author: William Woodruff
# ------------------------
# A Cinch plugin that keeps track of a user's last message,
# and allows them to apply a regex to it.
# ------------------------
# This code is licensed by William Woodruff under the MIT License.
# http://ope... |
# frozen_string_literal: true
module Pocky
class PackwerkLoader
def self.load(root_path, package_paths)
new(root_path, package_paths).load
end
private_class_method :new
def initialize(root_path, package_paths)
@root_path = root_path
@package_paths = package_paths
@packages = ... |
# Consider a character set consisting of letters, a space, and a point. Words
# consist of one or more, but at most 20 characters. An input text consists of
# one or more words separated from each other by one or more spaces and
# terminated by 0 or more spaces followed by a point. Input should be read from,
# and incl... |
# frozen_string_literal: true
require 'csv'
module VerifyRedirects
class Result
attr_reader :success, :start_url, :redirected_to, :expected_redirect
def initialize(success:, start_url:, redirected_to:, expected_redirect:)
@success = success
@start_url = start_url
@redirected_to = redirect... |
# frozen_string_literal: true
class AddGenderToStudents < ActiveRecord::Migration[5.0]
def change
add_column :students, :gender, :integer, default: 0, null: false
end
end
|
class AddProgressFieldToVideoFile < ActiveRecord::Migration
def change
add_column :video_files, :progress, :decimal
end
end
|
# require a login for the home controller
insert_into_file 'app/controllers/home_controller.rb', before: / def index/ do
<<-RUBY
before_action :require_login
RUBY
end
|
class StaticPagesController < ApplicationController
def front
redirect_to forum_path if logged_in?
end
end |
class DropInfomercialIpsumRequestsTable < ActiveRecord::Migration
def up
drop_table :infomercial_ipsum_requests
end
end
|
#Стандартная зарплата
class Zar_plata_min
def initialize(minimum)
@minimum = minimum
end
def get_salat
return @minimum
end
end
#Стандартный декоратор
class Decorator < Zar_plata_min
attr_accessor :salary
def initialize(component)
@salary = component
end
end
#С месечными 1
class Dec... |
#Implement octal to decimal conversion. Given an octal input string, your
#program should produce a decimal output.
class Octal
def initialize(number)
@number = number
end
def to_decimal
return 0 if invalid?
array_nums = @number.chars.map.with_index { |num, idx| num.to_i * 8**(@number.size - idx - ... |
# encoding: UTF-8
# Copyright 2011-2013 innoQ Deutschland GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... |
Rails.application.routes.draw do
devise_for :users
root 'application#angular'
resources :albums, only: [:index, :show]
resources :songs, only: [:index, :show]
resources :playlists, only: [:index, :show, :create]
# note the use of 'singular resourse' for routing without id
resource :play... |
require 'rails_helper'
RSpec.describe MaterialsController, :type => :controller do
before do
FactoryGirl.create :user
sign_in User.first
FactoryGirl.create :course
FactoryGirl.create :attending, role: 2
FactoryGirl.create :lesson_category
FactoryGirl.create :material_category
@file = Rac... |
describe Limbo::Rails::ParameterFilter do
before do
Rails.application.config.filter_parameters = [:password, :secret]
end
describe ".filter" do
context "is a hash" do
it "filters specified parameters" do
hash = { password: "secret", other: "visible", secret: "d" }
filtered_hash = Li... |
class AddStationRefToEstates < ActiveRecord::Migration[5.0]
def change
add_reference :estates, :station, foreign_key: true
end
end
|
# Fix extraction on case-insensitive file systems.
# Reported 4 Sep 2017 https://bugs.launchpad.net/qemu/+bug/1714750
# This is actually an issue with u-boot and may take some time to sort out.
class QemuDownloadStrategy < CurlDownloadStrategy
def stage
exclude = "#{name}-#{version}/roms/u-boot/scripts/Kconfig"
... |
# == Schema Information
#
# Table name: games
#
# id :bigint(8) not null, primary key
# title :text
# genre :text
# developer :text
# image :text
# list_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
class Game < ApplicationRecord... |
class AddEditableIsDefaultAndIndexOnEditableIsDefaultAndNameToSpreeRoles < ActiveRecord::Migration
def change
add_column :spree_roles, :editable, :boolean, :default => true
add_column :spree_roles, :is_default, :boolean, :default => false
add_index(:spree_roles, :name)
add_index(:spree_roles, :is_def... |
module Guerillarb
module Service
def self.service_request(library, number_of_lines)
lines = library.retrieve_lines(number_of_lines)
MultiJson.dump(lines)
end
def self.close_socket(socket)
socket.close unless socket.closed?
puts "Closing connection #{socket}"
end
def self.handle_connection(lib... |
require 'rails_helper'
RSpec.describe Item, type: :model do
before do
@item = FactoryBot.build(:item)
end
describe '商品出品機能' do
it "正しい値が入力されれば正しく登録される" do
expect(@item).to be_valid
end
it "商品画像を1枚つけることが必須であること" do
@item.image =nil
@item.valid?
expect(@item.errors.ful... |
# frozen_string_literal: true
module Errors
class Middleware
ERROR_DEFAULTS = { code: :internal_server_error, status: 500, message: "Sorry, something went wrong." }.freeze
# Any exceptions that are not configured will be mapped to 500 Internal Server Error (ERROR_DEFAULTS)
MAP_KNOWN_ERRORS = {
"Ab... |
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe RailsAdmin::Extensions::CanCanCan::AuthorizationAdapter do
let(:user) { double }
let(:controller) { double(_current_user: user, current_ability: MyAbility.new(user)) }
class MyAbility
include CanCan::Ability
def initialize(_user)
... |
class CitizensController < ApplicationController
before_action :set_citizen, only: %i[ show edit update destroy ]
# GET /citizens or /citizens.json
def index
return @citizens = Citizen.search(params[:query], match: :word_middle).results if params[:query]
@citizens = Citizen.all
end
# GET /citi... |
# frozen_string_literal: true
require "action_view" # Necessary for output buffer
require "triplet/version"
require "triplet/dsl"
require "triplet/template"
module Triplet
class Error < StandardError; end
def self.template(&block)
Template.new(&block).to_s
end
end
|
require "minitest"
require_relative 'jungle_beat'
# Test if things still work with an empty list
class JungleBeatTest < Minitest::Test
def test_takes_arguments_properly
jb = JungleBeat.new("deep dep dep deep")
assert_equal "deep", jb.head.data
end
def test_can_initialize_without_arguments
jb = Jung... |
require "rails_helper"
RSpec.describe Budget::Import do
let(:uploader) { create(:beis_user) }
let(:programme_activity) { create(:programme_activity) }
let(:new_direct_budget_attributes) do
{
"Type" => "0",
"Financial year" => "2011-2012",
"Budget amount" => "12345",
"Activity RODA ID... |
class TableUpdateService < ApplicationService
def initialize(table, attributes)
@table = table
@attributes = attributes
end
def call
create_or_update_records
end
private
def create_or_update_records
records_format_array.each do |record_attributes|
@table.find_or_initialize_by(ref: r... |
class CreateCoupons < ActiveRecord::Migration
def self.up
create_table :coupons do |t|
t.string :name
t.string :company
t.string :expires_on
t.string :fine_print
t.integer :days_to_regen
t.string :redeemable_at
t.timestamps
end
add_index :coupons, :id
end
def... |
Rails.application.routes.draw do
root 'home#index'
get '/sign-up/:profile_id/:email' => 'home#signup'
post '/sign-up' => 'home#createUser'
get '/logout' => 'home#logout'
get '/login' => 'home#login'
post '/login' => 'home#doLogin'
namespace :api do
namespace :v1 do
resources :logs, :defaults =>... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.