text stringlengths 10 2.61M |
|---|
class AddRodaIdentifier < ActiveRecord::Migration[6.0]
def change
change_table :activities do |t|
t.string :roda_identifier_fragment
t.string :roda_identifier_compound
t.index [:roda_identifier_compound]
end
end
end
|
module ListMore
module Repositories
class DBHelper < RepoHelper
def create_tables
db.exec <<-SQL
CREATE TABLE IF NOT EXISTS users(
id SERIAL PRIMARY KEY
, username VARCHAR UNIQUE
, password_digest VARCHAR
);
CREATE TABLE I... |
Pod::Spec.new do |s|
s.name = "RxResponderChain"
s.version = "2.0.0"
s.summary = "Notify Rx events via responder chain"
s.description = <<-DESC
`RxResponderChain` is an extension of `RxSwift`, `RxCocoa`.
It provides the way to notify Rx events via responder chain.
DESC
... |
class ChangeStartAndEndFromEvents < ActiveRecord::Migration
def change
rename_column :events, :start, :shoro
rename_column :events, :end, :payan
end
end
|
module Database
class Job < ActiveRecord::Base
serialize :settings
serialize :result
before_save do
self.status = 0 unless self.status
# elimina cuvintele din array - /i case insensitive - \b word boundary \b
%w[the of to and a in is it].each { |word| self.name = name.gsub(/\b#{w... |
module ApiHelper
include Rack::Test::Methods
def app
Rails.application
end
def json_includes key
JSON.parse(last_response.body)[key].should_not be_blank
end
def json_contains key, value
JSON.parse(last_response.body)[key].should == value
end
def json_should_not_contain key
JSON.parse... |
class ImageTextMixer
require "mini_magick"
BASE_IMAGE_PATH = Rails.root.join("app", "assets", "images", "twitter_post_v2.png")
# BASE_IMAGE_PATH = "#{RAILS_ROOT}/app/assets/images/twitter_post.png"
GRAVITY = 'west'
TEXT_POSITION = '40,0'
FONT = Rails.root.join("app", "assets", "fonts", "NotoSansJP-Black.ot... |
class ClassRoomsController < ApplicationController
before_action :find_classroom, only: [:show,:new_student,:update]
def index
@class_rooms = ClassRoom.all
end
def new
@class_room = ClassRoom.new
@teachers = Teacher.all
end
def create
@class_room =... |
require 'rails_helper'
describe "post a destination route", :type => :request do
before do
post '/destinations', params: { :city => 'test_city'}
end
it 'returns the city name' do
expect(JSON.parse(response.body)['city']).to eq('test_city')
end
it 'returns a created status' do
expect(response).... |
require 'spec_helper'
describe User do
it { should have_valid(:email).when('test@test.com') }
it { should_not have_valid(:email).when(nil, '', 'foo') }
it { should have_valid(:username).when('mallgoats') }
it { should_not have_valid(:username).when(nil, '') }
it { should have_many(:reviews)}
it { should ... |
class SourceFile < ActiveRecord::Base
set_table_name 'files'
def last_action_before_commit commit_id
all_actions = Action.where("file_id = ? AND commit_id <= ?", id, commit_id)
last_action = nil
all_actions.each do |a|
if last_action.nil? or a.commit_id > last_action.commit_id
last_action ... |
class Site
include MongoMapper::Document
key :user_ids, Array
many :users, :in => :user_ids
end
|
class CreateConshejointables < ActiveRecord::Migration[5.2]
def change
create_table :conshejointables do |t|
t.integer :contact_id, default: 0
t.integer :sheet_id, default: 0
t.integer :order_number, default: 0
t.timestamps
end
end
end
|
class CreateMeasurevalues < ActiveRecord::Migration
def change
create_table :measurevalues do |t|
t.integer :person_id
t.integer :measure_id
t.decimal :value, :precision => 8, :scale => 2
t.date :value_date
t.integer :created_by
t.timestamps null: false
end
end
end
|
require 'spec_helper'
describe ServiceType do
it "is an ActiveRecord mode" do
expect(ServiceType.superclass).to eq(ActiveRecord::Base)
end
it "is true when true" do
expect(true).to be_true
end
it "is valid with a name, description, agreement and active_record" do
service_type = ServiceType.new(
... |
class SampleGroupDestroyer < BaseServicer
attr_accessor :sample_group
def execute!
SampleGroup.transaction do
destroy_substructures
destroy_sample_group
end
end
private
def destroy_sample_group
sample_group.destroy
end
def destroy_substructures
sample_group.substructures.ea... |
require 'gosu'
include Gosu
#require_relative '../../features/step_definitions/sd_challenging_dom.rb'
require_relative '../..//Helen Rubymine project/pong_ruby/player.rb'
require_relative '../..//Helen Rubymine project/pong_ruby/ball.rb'
require_relative '../..//Helen Rubymine project/pong_ruby/scoreboard.rb'
class ... |
require "rails_helper"
describe Reports::PerformanceScore, type: :model do
let(:period) { Period.month("July 1 2020") }
let(:facility) { build(:facility) }
let(:reports_result) { double("Reports::Result") }
let(:perf_score) { Reports::PerformanceScore.new(region: facility, reports_result: reports_result, perio... |
# frozen_string_literal: true
Class.new(Nanoc::Filter) do
identifier :fix_contributor_brackets
def run(content, _params = {})
content.gsub(/ \[([^\]]+)\]\)?$/, ' \[\1\]')
end
end
|
require "spec_helper"
describe Patient do
it "should have a first name and second name" do
user = Patient.create!(first_name: "Andy", last_name: "Lindeman")
expect(user.first_name).to eq("Andy")
expect(user.last_name).to eq("Lindeman")
expect(user.name).to eq("Andy Lindeman")
end
it "should be ... |
require "formula"
class GnuUnits < Formula
homepage "https://www.gnu.org/software/units/"
url "http://ftpmirror.gnu.org/units/units-2.02.tar.gz"
mirror "http://ftp.gnu.org/gnu/units/units-2.02.tar.gz"
sha1 "e460371dc97034d17ce452e6b64991f7fd2d1409"
bottle do
sha1 "255fd50fc880467483ae2654d1c34cd45224784... |
class Users::RegistrationsController < Devise::RegistrationsController
before_action :has_invitation, only: [:new, :create]
def create
super
if create_succeeded?
@invitation.accepted! self.resource, Time.current
end
end
def update_resource resource, params
resource.update_without_passwor... |
foo = ["foo", "bar", "nax", "pax"]
puts foo[1]
puts foo.include?("jar")
puts foo.include?("foo")
puts ""
puts "Calling reverse will not mutate the array"
p foo.reverse
p foo
puts "However using a bang(!) will mutate the array"
p foo.reverse!
p foo
puts ""
# To convert to an array
p (1..15).to_a
puts ""
# random arr... |
class ChangeFeederIdFormatInProsumers < ActiveRecord::Migration
def up
change_column :prosumers, :feeder_id, :string
end
def down
change_column :prosumers, :feeder_id, "integer USING CAST(feeder_id AS integer)"
end
end
|
class PromotedOffer < ActiveRecord::Base
include PgSearch
pg_search_scope :search_by_name, :against => [:name, :location, :tag_list, :barcode], :using => {
:tsearch => {:prefix => true, :any_word => true}
}
def self.search(search)
PromotedOffer.search_by_name(search)
end
mount_uploader ... |
require 'spec_helper'
describe ActiveRecord do
it 'should load classes with non-default primary key' do
lambda {
YAML.load(Story.create.to_yaml)
}.should_not raise_error
end
it 'should load classes even if not in default scope' do
lambda {
YAML.load(Story.create(:scoped => false).to_... |
=begin
https://www.codewars.com/kata/52742f58faf5485cae000b9a
Additional Test Cases:
Test.assert_equals(format_duration(0), "now")
=end
# my solution 13/09/21
def format_duration(seconds)
return "now" if seconds == 0
combinations = {year: 60*60*24*365, day: 60*60*24, hour: 60*60, minute: 60, second: 1}
s = [... |
class ApplicationsController < ApplicationController
def index
@applications = Application.all
end
def show
@application = Application.find(params[:id])
@pets = Pet.search(params[:pet_of_interst_name])
@pet = @application.pets
end
def new
end
def create
application = Application.cre... |
class RecipeBox < ActiveRecord::Base
has_many :recipes
belongs_to :profile
end
|
class Dashboard < ActiveRecord::Base
belongs_to :student
belongs_to :job
end
|
class AddEndOfLineToGeoLine < ActiveRecord::Migration
def change
add_column :geo_lines, :end_of_line, :boolean, default: false
GeoLine.all.each do |line|
line.update_attributes end_of_line: true
end
end
end
|
# 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
# frozen_string_literal: true
WEEK = %w[понедельник вторник среда четверг пятница суббота воскресение].freeze
print(WEEK.select { |el| el.start_with? 'с' })
|
module Fog
module Compute
class Google
class Mock
def set_instance_template(_instance_group_manager, _instance_template)
# :no-coverage:
Fog::Mock.not_implemented
# :no-coverage:
end
end
class Real
def set_instance_template(instance_group_ma... |
class User < ActiveRecord::Base
devise :rememberable, :trackable, :omniauthable,
omniauth_providers: [:vkontakte]
def self.from_omniauth(auth)
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
user.name = auth.info.name
user.image = auth.info.image
user.profile_... |
# 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
# User factory
FactoryGirl.define do
factory :user do
username 'developer'
email 'developer@example.com'
firstname 'Dev'
lastname 'Eloper'
password_salt Authlogic::Random.hex_token
crypted_password { Authlogic::CryptoProviders::Sha512.encrypt("#{username}#{password_salt}") }
persistence_to... |
Dado("que apresentado o fomulário para autenticar no AgroHUB") do
@login= LoginPage.new
@login.abrirUrl
end
Quando("faço com login e-mail ... |
require "./q7/menu"
class Q7::Drink < Q7::Menu
attr_accessor :amount
def initialize(name:, price:, amount:)
super(name: name, price: price)
@amount = amount
end
end
|
# frozen_string_literal: true
# contains logic for basic moves for all pieces
class BasicMovement
attr_reader :row, :column, :board
def initialize(board = nil, row = nil, column = nil)
@board = board
@row = row
@column = column
end
def update_pieces(board, coords)
@board = board
@row = co... |
require "pakyow_helper"
RSpec.describe "Links", type: :feature do
def rom
Pakyow::Config.app.rom
end
def create_link(attributes)
attributes = attributes.merge(created_at: Time.now, updated_at: Time.now)
rom.command(:links).create.call(attributes)
end
def delete_all_links
# TODO this sure is... |
require 'rails_helper'
RSpec.describe User, type: :model do
before do
@user = FactoryBot.build(:user)
end
describe 'ユーザー新規登録' do
context '新規登録できるとき' do
it 'nickname,email,password,password_confirmation,last_name,first_name,last_name_furigana,first_name_furigana,birthdayが存在すると登録できる' do
expe... |
require 'test_helper'
class TeacherTest < ActiveSupport::TestCase
should have_many(:schedules).dependent(:destroy)
should have_many(:subjects).through(:schedules)
should have_many(:klasses).through(:schedules)
should validate_presence_of(:name)
should ensure_inclusion_of(:age).in_range(1..100)
should ens... |
#!/usr/bin/env ruby
# Author: Courtney Cotton <cotton@cottoncourtney.com> 5-26-2015
# Desc: This script takes a list of IPs from a .txt file and grabs the
# correct subnet/cidr from a provided FTP networks file.
# Libraries/Gems
require 'optparse'
require 'net/ftp'
require 'fileutils'
require 'ipaddr'
# Represents a... |
module Ricer::Plugins::Conf
class Help < Ricer::Plugin
trigger_is :help
bruteforce_protected :always => false
has_usage :execute_list, ''
def execute_list
return if bruteforcing? # Manual bruteforce protection
grouped = collect_groups
grouped = Hash[grouped.sort]
... |
class Gender < ActiveRecord::Base
def name
I18n.t("catalogs.gender.#{i18n_name}")
end
def to_s
name
end
def self.ids_for_male_and_female_entries
@ids_for_male_and_female_entries ||= self.where(:i18n_name => ['male','female']).select(:id).map(&:id)
end
def self.all_with_all_option
[Stru... |
class ConversationsController < ApplicationController
before_action :set_conversation, only: [:replay, :show]
def index
@conversations = current_user.mailbox.conversations
end
def show
@conversation = current_user.mailbox.conversations.find(params[:id])
@messages = @conversation.messages.orde... |
class AddSettingsToTeamBotInstallation < ActiveRecord::Migration[4.2]
def change
config = CheckConfig.get('clamav_service_path')
CheckConfig.set('clamav_service_path', nil)
add_column(:users, :settings, :text) unless column_exists?(:users, :settings)
add_column(:team_users, :settings, :text) unless c... |
class Public::AddressesController < ApplicationController
before_action :authenticate_customer!
def index
@addresses = Address.all.order(created_at: :desc)
@address = Address.new
end
def create
@address = Address.new(add_params)
@address.customer_id = current_customer.id
if @address.sa... |
# typed: false
class Message < ApplicationRecord
validates :content, presence: true
belongs_to :game
end
|
class Property < ActiveRecord::Base
DOMAIN_HEAD_REGEX = '(?:[A-Z0-9\-]+\.)+'.freeze
DOMAIN_TLD_REGEX = '(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|jobs|museum|local|asia)'.freeze
DOMAIN_REGEX = /\A#{DOMAIN_HEAD_REGEX}#{DOMAIN_TLD_REGEX}\z/i
has_many :campaigns
has_many :s... |
module SessionsHelper
def sign_in(company)
cookies.permanent[:remember_token] = company.remember_token
current_company = company
end
def signed_in?
!current_company.nil?
end
def current_company= (company)
@current_company = company
end
def current_company
@current_company ||= company_fro... |
require 'spec_helper'
RSpec.describe Movie, type: :model do
let(:movie) { build(:movie, title: "300", plot: "...") }
it "must be valid" do
expect(movie).to be_valid
end
end
|
require 'helper'
=begin
Signatures in tests generated by existing PHP signatory, to ensure
compatibility.
http://github.com/matchu/openneo-auth-server/blob/master/openneo_auth_signatory.class.php
=end
class TestOpenneoAuthSignatory < Test::Unit::TestCase
def setup
@signatory = Openneo::Auth::Signatory.ne... |
require 'docx_builder'
plan_struct = Struct.new(:name, :areas, :goals_by_area, :objectives_by_goal)
area_struct = Struct.new(:description, :id)
goal_struct = Struct.new(:description, :id)
objective_struct = Struct.new(:description)
@plan = plan_struct.new
@plan.name = 'Business Plan for 2011'
@plan.areas = [area_stru... |
require 'test_helper'
class TodoTest < ActiveSupport::TestCase
def todo
todo = todos(:one)
end
def user
@user ||= users(:one)
end
def member
@member ||= users(:two)
end
def event
Event.last
end
test 'finished shoulde be make finished to true' do
todo.finished!
assert todo... |
require 'rails_helper'
require 'web_helper'
feature 'liking posts' do
it 'a user can endorse a review on the index page, which increments the endorsement count', js: true do
create_user
create_post
sign_in
visit '/posts'
click_link 'Like'
expect(page).to have_content("1 like")
end
scena... |
module I18nBackendDatabase
class Engine < Rails::Engine
initializer "i18n_backend_database.initialize" do |app|
I18n.backend = I18n::Backend::Database.new
end
initializer "common.init" do |app|
# Publish #{root}/public path so it can be included at the app level
if app.config.serve_sta... |
class PollChoice < ActiveRecord::Base
belongs_to :poll
has_many :votes, dependent: :destroy
has_many :citizens, through: :votes
normalize_attribute :name, with: [:strip, :blank] do |value|
value.present? && value.is_a?(String) ? value.upcase : value
end
after_create do
poll.keyword_listeners.creat... |
require_dependency "administration/application_controller"
module Administration
class ArticleTypesController < ApplicationController
# Require this in order to avoid uninitialized constant
require "#{Article::Engine.root}/app/models/article/publication.rb"
def index
@types = Article::Type.all.rev... |
class QuotesController < ApplicationController
def new
@accountant = Accountant.find(params[:accountant][:accountant_id])
@enquiry = Enquiry.find(params[:accountant][:id])
@quote = Quote.new(enquiry: @enquiry)
authorize @quote
end
def new_admin
authorize current_user
@quote = Quote.new
... |
class AddProgressiveVolumeDiscountToVariants < ActiveRecord::Migration
def self.up
add_column :variants, :progressive_volume_discount, :boolean,
:null => false, :default => 0
end
def self.down
remove_column :variants, :progressive_volume_discount
end
end
|
class SiteOptionsController < ApplicationController
before_action :set_site_option, only: [:show, :edit, :update, :destroy]
# GET /site_options
# GET /site_options.json
def index
@site_options = SiteOption.page params[:page]
end
# GET /site_options/1
# GET /site_options/1.json
def show
end
# ... |
require "rails_helper"
RSpec.describe Api::V4::CallResultsController, type: :controller do
let(:request_user) { create(:user) }
let(:request_facility_group) { request_user.facility.facility_group }
let(:request_facility) { create(:facility, facility_group: request_facility_group) }
let(:model) { CallResult }
... |
require "rake"
class Link
include Rake::DSL
def initialize(target, source)
@target = target
@source = source
end
def create
log { File.symlink(@source, @target) }
rescue Exception
print "#{@target} already exists. Overwrite? [yn]: "
STDIN.gets.chomp == "y" and rm_rf(@target) and retry
... |
#!/usr/bin/env ruby -wKU
# Bilal Hussain
# encoding: UTF-8
require 'optparse'
Help = %{Usage: #{File.basename $0} [-t] $regex_match $regex_sub [glob]
Example: #{File.basename $0} -t ".*([0-9]+).mp3" "Track \\1.mp3"}
options = {excludes:[]}; glob = '*'
OptionParser.new do |opts|
opts.banner = Help
opts.on("-t", "--... |
class UserResponseCache
def initialize(user, question)
#get response_options id's for response_options_selections
responses = user.response_option_selections
.where(:response_option_id => question.response_options.pluck(:id)).select([:id, :response_option_id])
@map = {}
responses.eac... |
class Provider::Admin::CMS::LayoutsController < Provider::Admin::CMS::TemplatesController
private
def templates
current_account.layouts
end
end
|
require 'rails_helper'
RSpec.describe ShipmentItemsController, type: :controller do
let!(:product_1) { FactoryGirl.create :product, sku: '123456' }
let!(:product_2) { FactoryGirl.create :product, sku: '654321' }
let (:order) do
FactoryGirl.create :processing_order,
item_attributes: [
{
... |
require 'rails_helper'
RSpec.describe Event, type: :model do
context "Every new event needs" do
it(:location) {should_not == nil}
it(:event_date) {should_not == nil}
end
end
|
require "aethyr/core/actions/commands/command_action"
module Aethyr
module Core
module Actions
module Move
class MoveCommand < Aethyr::Extend::CommandAction
def initialize(actor, **data)
super(actor, **data)
end
def action
event = @data.dup
... |
Rails.application.routes.draw do
namespace :api do # Change URLs to /api/<whatever>
resources :locations
resources :characters
end
#Do not place any routes below this one
get '*other', to: 'static#index' # For production
end
|
class BrocadeHost < Host
has_many :zones, :foreign_key => "host_id", :dependent => :destroy
has_many :brocadePorts, :foreign_key => "host_id", :dependent => :destroy
def load_switch_ports
lines = exec('switchshow').split("\n")
self.is_principal = false
if m = /switchRole:(.*)/.match(lines[4])
... |
require './test_helper'
require 'google_books'
require 'job'
ENV['RACK_ENV'] = 'test'
class GoogleBooksTest < Test::Unit::TestCase
include Rack::Test::Methods
def app
GoogleBooks
end
def test_index_should_save_page_to_redis_when_required
# by stubbing Redis.get in this case, it simulates a situa... |
# Asset route definitions
class App < Sinatra::Base
# compile haml partials, for angular templating
get "/partials/:file" do
# path = request.path_info.gsub(/\.html$/, "") + ".haml"
path = request.path_info
ext = File.extname(path)[1..-1]
path = root_path("app", path)
if File.exists?(path)
... |
class AddDeletedByToLeagueMatchComms < ActiveRecord::Migration[5.0]
def change
add_column :league_match_comms, :deleted_at, :datetime, null: true
add_column :league_match_comms, :deleted_by_id, :integer, null: true, default: nil, index: true
add_foreign_key :league_match_comms, :users, column: :deleted_by... |
class JobsController < ApplicationController
def show
@jobs = Job.all
respond_to do |format|
format.json
end
end
end
|
class ReviewsController < ApplicationController
before_filter :authorize
def create
@review = Review.new(review_params)
@product = Product.find_by(id: params[:product_id])
# after @review has been initialized, but before calling .save on it:
@review.user = current_user
if @review.save
... |
class CubedController < ApplicationController
def random
@number=10
if params[:number].to_i.even?
"even"
else
"odd"
end
render "random.html.erb"
end
end
|
class Tank < GameObject
SHOOT_DELAY = 500
attr_accessor :x, :y, :gun_angle, :direction, :sounds, :physics, :throttle_down
def initialize(object_pool, input)
super(object_pool)
@input = input
@input.control(self)
@physics = TankPhysics.new(self, object_pool)
@graphics... |
class Ability
include CanCan::Ability
def initialize(user)
@user = user
if user.is_admin?
can [:destroy_all, :destroy, :index, :create, :show], Order
can [:mark_availability, :destroy, :index, :create, :show], Item
else
can [:destroy, :create, :show], Order
end
end
end |
class TeamsController < ApplicationController
before_action :set_team, only: [:show, :edit, :update, :leave, :destroy]
before_action :ensure_that_signed_in
# GET /teams
# GET /teams.json
def index
@teams = current_user.recent_teams
end
# GET /teams/1
# GET /teams/1.json
def show
end
# GET /... |
require 'rails_helper'
RSpec.describe Publisher, type: :model do
context "relationships" do
it { should have_many :books }
end
end
|
module Travel
class CLI
attr_accessor :api
def initialize
self.api = API.new
end
def call
puts "welcome user"
puts "To see locations for travel, enter 'begin'"
puts "To exit the travel program, please enter 'exit'"
... |
require 'rails_helper'
RSpec.describe VariantSerializer do
let(:variant) { create(:variant) }
let(:expected_serializer_hash) do
{ waist: variant.waist,
length: variant.length,
style: variant.style,
count: variant.count }
end
subject(:serializer_hash) do
VariantSerializer.new(variant... |
require_relative '_helper'
require 'dbp/book_compiler/markdown_to_tex/translator'
module DBP::BookCompiler::MarkdownToTex
describe Translator, 'token patterns' do
let(:scanner) { StringScanner.new(input) }
let(:pattern) { Translator::TOKENS[subject] }
before do
scanner.scan(pattern)
end
d... |
class SendMessageJob < ApplicationJob
queue_as :default
def perform(message, user_name)
me = ApplicationController.render(
partial: 'messages/me',
locals: {message: message}
)
others = ApplicationController.render(
partial: 'messages/others',
locals: {message: message}
)
... |
class ChangeColumntemplabelsBarcodeToText < ActiveRecord::Migration
def change
change_column :templabels, :barcode, :string
end
end
|
require 'rails_helper'
describe 'User login', type: :request do
let!(:test_user) { create(:user) }
context 'Sending valid data' do
it 'successfully logs in' do
post api_v1_sign_in_path, params: {password: 'partnership'}
token = json['token']
expect(response).to have_http_status(:success)
... |
class Cliente < ActiveRecord::Base
has_many :qualificacoes
validates_presence_of :nome, message: "Nome deve ser preenchido"
validates_uniqueness_of :nome, message: "Nome ja cadastrado"
validates_numericality_of :idade, greater_than: 0,
less_than: 100,
... |
class Person
attr_accessor:name
# def name(name)
# @name=name
# end
def speak
"Hi, my name is #{@name}."
end
end
class Student < Person
def learn
"I get it!"
end
end
class Instructor < Person
def teach
"Everything in Ruby is an Object."
end
end
instructor=Instructor.new
instructor.name="Chris"
put... |
require 'rails_helper'
RSpec.describe EventPolicy, type: :policy do
let(:user) { FactoryBot.create(:user) }
let(:event) { FactoryBot.create(:event, user: user) }
context 'when owner' do
subject { described_class.new(user, event) }
it { is_expected.to permit_actions(%i[edit update destroy]) }
it { i... |
class DropPostCategoryFromPosts < ActiveRecord::Migration
def change
remove_column :posts, :post_category_id
end
end
|
module RedmineTwitterBootstrap
module Helper
def nav_list_tag(caption, path)
active = 'active' if params[:controller] == path[:controller] and params[:action] == path[:action]
content_tag(:li, class: active) do
link_to caption, path
end.html_safe
end
def breadcrumb_tag(active, l... |
class RenameEdicaoLivroToBookEdition < ActiveRecord::Migration[6.0]
def up
rename_column :edicoes_livros, :nome, :name
rename_column :edicoes_livros, :numero, :number
rename_column :edicoes_livros, :editora, :publisher
rename_column :edicoes_livros, :idioma, :language
rename_column :edicoes_livros... |
post '/error' do
response['Access-Control-Allow-Origin'] = '*'
if params[:url]
url_id = Url.rootify_find_create(params[:url]).id
end
if params[:user_id]
begin
decoded = Base64.decode64(params[:user_id].encode('ascii-8bit'))
decrypted = Encryptor.decrypt(decoded, key: SECRET_KEY)
para... |
require "rails_helper"
RSpec.describe TeleconsultationMedicalOfficer, type: :model do
describe "default scope" do
it "contains only users who can teleconsult" do
users = [create(:teleconsultation_medical_officer),
create(:teleconsultation_medical_officer, teleconsultation_facilities: [])]
ex... |
class User < ApplicationRecord
devise :authy_authenticatable, :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable,
:confirmable, :lockable, :trackable
has_many :profiles, dependent: :destroy
has_many :messages, dependent: :destroy
has_many :access_grants, clas... |
require 'pry'
def second_supply_for_fourth_of_july(holiday_hash)
holiday_hash[:summer][:fourth_of_july][1]
end
def add_supply_to_winter_holidays(holiday_hash, supply)
holiday_hash[:winter][:christmas] << supply
holiday_hash[:winter][:new_years] << supply
end
def add_supply_to_memorial_day(holiday_hash, supply... |
#!/usr/bin/ruby
def translateFile(f)
infile = File.new(f,"r")
lines = []
while (line = infile.gets)
unless (line.strip()[0..0]=="#")
values = line.strip.split(/\s+/)
lines.push "{label:'',val:%i,lat:%.2f,lng:%.2f}" % values
end
end
outfile = File.new("%s.json" % File.basename(f), "w")
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.