text stringlengths 10 2.61M |
|---|
# 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: 'Emanu... |
# frozen_string_literal: true
module Decidim
module Opinions
module Log
class ResourcePresenter < Decidim::Log::ResourcePresenter
private
# Private: Presents resource name.
#
# Returns an HTML-safe String.
def present_resource_name
if resource.present?
... |
Given(/^I have chosen "(.*?)"$/) do |text|
visit '/game'
choose("choice", :option => "Rock")
click_button "Lets go!"
end
When(/^I am taken to the end game page$/) do
expect(current_path).to eq('/end_game')
end
Then(/^I will see "(.*?)"$/) do |text|
expect(page).to have_content text
end |
class Blogpost < ApplicationRecord
mount_uploader :blogimage, BlogimageUploader
has_and_belongs_to_many :tags
end
|
FactoryGirl.define do
factory :user do
first_name 'Harry'
last_name 'Potter'
email { generate :email }
verified_at Time.now
password 'expecto patronum'
end
factory :invaild_user, parent: :user do
first_name nil
end
factory :unverified_user, parent: :user do
first_name 'Lucky'
... |
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
Gem::Specification.new do |s|
s.name = 'airbrake_symbolicate'
s.version = '0.2.1'
s.date = Time.now.strftime('%Y-%m-%d')
s.authors = ['Brett Gibson']
s.email = ['brettdgibson@gmail.com']
s.homepage = ''
s.summa... |
class Question
include Mongoid::Document
field :name
# Type can be Text, Radio, Range
field :answer_type
field :answers_radio, type: Array
field :answer_range, type: Hash
embedded_in :test
end
|
require_relative 'demo_app_page'
class CategoriesListPage < DemoAppPage
path '/categories/'
validate :title, /\ADemo web application - Categories\z/
element :new_category_button, :xpath, "//a[@href='/categories/new']"
element :edit_btn, :xpath, ->(name:) { "//div[contains(.,'#{name}')]/div/a[contains(text(), '... |
# frozen_string_literal: true
module Common
module Client
module Configuration
class Base
include Singleton
class_attribute :open_timeout
class_attribute :read_timeout
class_attribute :request_types
class_attribute :user_agent
class_attribute :base_request_h... |
desc "期限の3日前になるとメールを送信する"
task notice_deadline: :environment do
time_range = (Time.now.midnight + 3.day)
products = Product.where('deadline' => time_range)
products.each do |product|
NoticeMailer.with(product: product).send_notice_deadline.deliver_now
end
end
desc "楽天レシピAPIを使ってレシピ... |
# frozen_string_literal: true
require 'jiji/utils/requires'
Jiji::Utils::Requires.require_all('jiji/model')
module Jiji::Test
class DataBuilder
include Jiji::Model::Trading
def initialize
Jiji::Model::Logging::LogData.drop
Jiji::Model::Notification::Notification.drop
Jiji::Db::CreateCapp... |
class Flight < ActiveRecord::Base
default_scope { order("date ASC") }
belongs_to :from_airport, class_name: "Airport"
belongs_to :to_airport, class_name: "Airport"
has_many :bookings
end
|
class Vidsub < ApplicationRecord
belongs_to :subcategory
has_many :videofxes
end
|
describe 'CNE Consumer' do
before(:all) do
@consumer = CNEConsumer.new
@consumer2 = CNEConsumer.new('')
WebMock.allow_net_connect!
end
it 'should raise argument error when not provided location codes' do
expect{@consumer.gas_stations_by_location()}.to raise_error(ArgumentError)
end
it 'shoul... |
require 'test_helper'
class PromptItemsControllerTest < ActionController::TestCase
setup do
@prompt_item = prompt_items(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:prompt_items)
end
test "should get new" do
get :new
assert_respons... |
require 'svntl'
include SvnTimeline::TemplateHelpers
context "Method vertical_text" do
specify "should return empty string on empty string" do
vertical_text("").should == ""
end
specify "should return no <br />s for one character" do
vertical_text("a").should == "a"
end
specify "should return singl... |
class RemoveSitterIdFromRating < ActiveRecord::Migration[5.0]
def change
remove_column :ratings, :sitter_id, :integer
end
end
|
class AddUserToYorums < ActiveRecord::Migration[5.2]
def change
add_reference :yorums, :user, foreign_key: true
end
end
|
# frozen_string_literal: true
class Document
class OwnSerializer < ActiveModel::Serializer
attributes :document_id, :title
has_many :shares
def document_id
object.id.to_s
end
end
end
|
require 'test_helper'
class ProductTest < ActiveSupport::TestCase
fixtures :products
test "product attribute can not be empt" do
product = Product.new
assert product.invalid?
assert product.errors[:title].any?
assert product.errors[:description].any?
assert product.errors[:price].any?
assert product.err... |
UserType = GraphQL::ObjectType.define do
name 'User'
description 'A person who uses our app'
interfaces [GraphQL::Relay::Node.interface]
global_id_field :id
field :email, !types.String, "The name of this person"
end
|
class ValidateWordService
def initialize(word)
@word = word
@conn = Faraday.new('https://od-api.oxforddictionaries.com/api/v1')
end
def json
get_json("inflections/en/#{@word}")
end
private
attr_reader :conn, :word
def get_json(path)
response ||= @conn.get(path) do |req|
re... |
module Kantox
module Chronoscope
# Dummy module to be used in production-like environments.
module Dummy
# rubocop:disable Style/MethodName
# rubocop:disable Style/OpMethod
def ⌚(*args)
yield(*args) if block_given?
end
def ⌛(*)
{}
end
# rubocop:enable... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe User, type: :model do
let!(:me) { create(:user) }
let!(:others) { create(:user) }
it { is_expected.to validate_presence_of :email }
it { is_expected.to validate_presence_of :name }
it { is_expected.to validate_presence_of :password }
it {... |
require "rails_helper"
describe Scheduler::HourlySchedule do
before do
@coach = create(:coach)
@availability = create(:availability,
coach: @coach,
start_at: 1.day.from_now.change(usec: 0),
end_at: 1.week.from_now.change(usec: 0... |
module Topograf
class Parser
def initialize(log, filtered_urls = [])
@log = log
@filtered_urls = filtered_urls
end
def parse
lines = @log.split("\n")
lines = requests(lines)
results = []
lines.each do |line|
if line.include? 'GET'
results << item(l... |
require 'rake'
Gem::Specification.new do |s|
s.name = 'word_wrapper'
s.version = '0.5.0'
s.date = '2012-12-30'
s.summary = "Pure ruby word wrapping"
s.description = "Word wrapping implementation in ruby. Includes a naive greedy algorithm (fast) and Knuth's minimum raggedness algorithm f... |
class ServiceItem < ActiveRecord::Base
belongs_to :auto_model
has_one :customer_service_item_ship
def auto_brand_id
@auto_brands = AutoBrand.all
end
end
|
require 'spec_helper'
module SalarySummary
module Entities
describe Salary do
let(:id) { BSON::ObjectId.new }
it_behaves_like 'a Salary entity as a document'
subject { described_class.new(id: id, amount: 200.0, period: Date.parse('January, 2016')) }
describe '#year' do
it 'retu... |
And(/I note the Time Off Details on the employee summary page$/i) do
@browser.element(text: 'Time Off Info').click
table = @browser.table(class: 'table', index: 2)
table.wait_until_present(10)
@time_off_summary = table.to_a
end
When(/I enter a (Vacation|Sick|Floating Holiday|Other) request for a (\w+) day that... |
json.array!(@users) do |user|
json.extract! user, :id, :u_name, :u_email, :u_password, :u_picture
json.url user_url(user, format: :json)
end
|
class MaxChainsController < ApplicationController
include MyUtility
before_action :set_max_chain, only: [:show, :edit, :update, :destroy]
# GET /max_chains
def index
placeholder_set
param_set
@count = MaxChain.notnil().search(params[:q]).result.count()
@search = MaxChain.notnil().page(params[:p... |
require 'spec_helper'
describe Users::CharitiesController do
let(:charity) { mock_model(Charity, :name => 'Alameda Flock Consortium') }
let(:user) { create(:user) }
let(:params) { {'hi' => 'mate'} }
describe "for anonymous users" do
it "GET :new redirects" do
get :new
response.should redir... |
module RadioTune
module TestDatabase
def with_database
database = TestDatabase.new
database.create
database.seed
yield database if block_given?
ensure
database.clear
database.close
end
class TestDatabase
def create
connection.execute %{
CR... |
#
# testing rufus-json
#
# Fri Jul 31 13:05:37 JST 2009
#
require 'test/unit'
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'rufus/json'
require 'rubygems'
JSON_LIB = ARGV[0]
require JSON_LIB
if JSON_LIB == 'active_support'
Rufus::Json.backend = :active
else
Rufus::Json.detect_backend
end
... |
class SeasonSerializer < ActiveModel::Serializer
attributes :id, :name, :active_from, :active_to, :created_at
has_many :series
end
|
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def label_and_value(label, value)
content_tag(:p, content_tag(:span, label, :class => "strong") + value)
end
def label_and_contact_links(label, contacts)
result = '<p><span class="strong">' + ... |
# typed: strict
# frozen_string_literal: true
# Handles all `const`/`prop` calls, creating accessor methods, and compiles them for later usage at the class level
# in creating a constructor
class YARDSorbet::StructHandler < YARD::Handlers::Ruby::Base
extend T::Sig
handles method_call(:const), method_call(:prop)
... |
class AddPostsCountToGroup < ActiveRecord::Migration
def change
add_column :groups, :posts_count, :integer, :default => 0r
end
end
|
class Tweet
attr_accessor :message, :user_id
# ALL = []
def self.all
# ALL
sql = "SELECT * FROM tweets"
tweets = DB[:conn].execute(sql)
# right now this returns an array of hashes
# we want this to return an array of tweets
tweets
end
def initialize(props={})
@message = props['m... |
$synonyms = [
["sketch", "sketch lines", "doodle", "scetch", "sketch dump", "sketchdump", "sketches", "sketching", "sketch book"],
["digital", "digital drawing", "digital art", "digital artwork", "digital media", "digital media artwork", "digital painting"],
["black and white", "b&w", "b/w", "baw", "black/white",... |
module Simpler
module Middleware
class Logger
DEFAULT_FILE_NANE = 'log/app.log'.freeze
def initialize(app, file_name = nil)
@app = app
@file_name = file_name
end
def call(env)
status, headers, body = @app.call(env)
log(message(status, headers, env))
... |
require 'test_helper'
class TaxasControllerTest < ActionDispatch::IntegrationTest
setup do
@taxa = taxas(:one)
end
test "should get index" do
get taxas_url
assert_response :success
end
test "should get new" do
get new_taxa_url
assert_response :success
end
test "should create taxa" ... |
FactoryGirl.define do
factory :hotel do
name { Faker::Lorem.characters(rand(3..49)) }
description { Faker::Lorem.sentence(rand(4..6),false,6) }
price { Faker::Number.positive(1.00,5000.00) }
rating { Faker::Number.positive(1,5) }
#association :review, factory: :review
end
end
|
module ManagementConsultancy
module Admin
class Upload < ApplicationRecord
include AASM
self.table_name = 'management_consultancy_admin_uploads'
default_scope { order(created_at: :desc) }
mount_uploader :suppliers_data, ManagementConsultancyFileUploader
attr_accessor :suppliers_dat... |
require 'sphere'
class Order
def initialize(shop, sphere_order_id)
@sphere_order_id = sphere_order_id
@project_key = shop.project_key
client_id = shop.sphere_client_id
client_secret = shop.sphere_client_secret
Rails.logger.debug "sphere_client_id: #{shop.sphere_client_id}"
Rails.logger.debug... |
class AddLongitudeToDrugstores < ActiveRecord::Migration
def change
add_column :drugstores, :longitude, :float
end
end
|
# Programmer: Chris Bunch
require 'task_info'
class ExodusTaskInfo
def initialize(dispatched_babel_tasks)
@babel_tasks = dispatched_babel_tasks
end
def to_s
method_missing(:to_s)
end
def method_missing(id, *args, &block)
loop {
@babel_tasks.each_with_index { |task, i|
beg... |
require 'digest/sha1'
class User < ActiveRecord::Base
include Authentication
include Authentication::ByPassword
include Authentication::ByCookieToken
include Authorization::AasmRoles
# Validations
validates_presence_of :login, :if => :not_using_openid?
validates_length_of :login, :within => 3..40, :if =... |
require 'rails_helper'
RSpec.describe "ユーザーのリクエストテスト", type: :request do
describe 'GET #show' do
context 'ユーザーが存在する場合' do
before do
user1 = FactoryBot.create(:user_tanaka)
get user_url user1.id
end
it 'リクエストが成功すること' do
expect(response.status).to eq 200
end
... |
Then /^I should be logged in$/ do
@screen.welcome_screen.welcomeScreen
end
When /^I touch main menu$/ do
@screen.welcome_screen.touchMainMenu
end
And /^I select log out option$/ do
@screen.welcome_screen.logOut
end
And /^I select reload data option$/ do
@screen.welcome_screen.reloadData
end
Then... |
require 'spec_helper'
describe Micropost do
let(:user) { FactoryGirl.create(:user) } # тащит все данные юзера
before { @micropost = user.microposts.build(content: "Lorem ipsum") } # ???
subject { @micropost }
it { should respond_to(:content) } # имеет сам контент
it { should respond_to(:user_id) } # имеет... |
require 'rails_helper'
RSpec.describe CartItemsController, type: :controller do
let!(:user) { create(:user) }
let!(:item) { create(:item) }
before do
login_user user
end
describe 'POST#create' do
context '有効なパラメータの場合' do
before do
@cart_item = attributes_for(:cart_item)
post :create, pa... |
Rails.application.routes.draw do
root to: "welcome#home"
resources :contacts, only: :create
end
|
class ApplicationController < ActionController::Base
protect_from_forgery
protected
def jsonify(items)
items.to_json(:include => {:user => {:only => :username}})
end
end
|
# frozen_string_literal: true
require 'dotenv/load'
require 'bundler/setup'
require 'rollbar_api'
project_name = ENV['ROLLBAR_PROJECT_NAME']
project_access_token = ENV['ROLLBAR_PROJECT_ACCESS_TOKEN']
raise 'Must specify ROLLBAR_PROJECT_NAME in .env' if project_name.blank?
raise 'Must specify ROLLBAR_ACCOUNT_ACCESS_T... |
feature "Edit a Gsa18F procurement" do
context "User is requester" do
context "procurement has pending status" do
scenario "can be modified" do
requester = create(:user, client_slug: "gsa18f")
procurement = create(:gsa18f_procurement, :with_steps, requester: requester, urgency: 10)
p... |
require "minitest_helper"
require "chandler/cli"
class Chandler::CLITest < Minitest::Test
include LoggerMocks
ParserStub = Struct.new(:args, :config, :usage)
def setup
@args = []
@config = Chandler::Configuration.new
@config.logger = new_logger
@parser = ParserStub.new(@args, @config, "usage")
... |
# train:
# *** has type which set on initialize: cargo, passenger, number of wagons
# train can do:
# *** increase speed
# *** show current speed
# *** brake
# *** show number on wagons
# *** add / detach wagons one by one
# *** add / detach wagons can if train not move
# *** accept route
# *** move between stations on... |
class AddSomeColumnsToZipCodes < ActiveRecord::Migration
def up
execute <<-SQL
alter table addresses drop constraint addresses_zip_code_fkey;
drop table zip_codes;
create table zip_codes (
zip varchar(16) not null,
city varchar(255) not null,
state_abbreviation varchar(2)... |
module ApplicationHelper
def get_start_date
Time.now.strftime('%d-%m-%Y')
end
def get_end_date
Time.now.strftime('%d-%m-%Y')
end
def current_date
Time.now.strftime('%d-%m-%Y')
end
def admin_user?
(current_user.rol_id == 1)
end
def has_admin_credentials?
admin_user? ? true : (r... |
# frozen_string_literal: true
require "redcarpet"
module Decidim
module Opinions
# This class parses a participatory text document in markdown and
# produces Opinions in the form of sections and articles.
#
# This implementation uses Redcarpet Base renderer.
# Redcarpet::Render::Base performs a ... |
class AddCauseOfDeathToPostgres < ActiveRecord::Migration[5.0]
def up
execute <<-SQL
CREATE TYPE cause_of_death AS ENUM ('choking', 'shooting', 'beating', 'taser', 'vehicular', 'medical neglect', 'response to medical emergency', 'suicide')
SQL
add_column :cases, :cause_of_death, :cause_of_death, in... |
# frozen_string_literal: true
class User
class DocumentSharingDecorator
def initialize(user)
@user = user
end
def documents
own_shares.merge(guest_shares)
end
private
def own_shares
{ own_shares: @user.documents.includes(:shares).map do |doc|
Documen... |
class LectureRelations < ActiveRecord::Migration[6.0]
def change
add_reference :user_lecture_timestamps, :user, foreign_key: true
add_reference :user_lecture_timestamps, :lecture_timestamp, foreign_key: true
add_reference :question_lecture_timestamps, :question, foreign_key: true
add_reference :quest... |
# -*- coding: utf-8 -*-
require 'spec_helper'
describe Shortener::ShortenedUrl do
it { should belong_to(:owner) }
it { should validate_presence_of :url }
shared_examples_for "shortened url" do
let(:short_url) { Shortener::ShortenedUrl.generate!(long_url, owner) }
it "should be shortened" do
short_... |
require_relative "list_node"
# Returns the list reversed
def reverse(head)
previous = nil
current = head
while current
nextNode = current.next_node
current.next_node = previous
previous = current
current = nextNode
end
head = previous
return head
end
# Block 1 - Create the l... |
module Charts
class CalculateCostBreakdown
prepend SimpleCommand
def initialize(current_user, args = {})
@user = current_user
@args = args
end
def call
month = Date.parse("#{@args[:month]} #{@args[:year]}")
tasks = Cultivation::Task.where(:start_date.lte => month.beginning_of... |
require 'test_helper'
class SchesControllerTest < ActionDispatch::IntegrationTest
setup do
@sch = sches(:one)
end
test "should get index" do
get sches_url
assert_response :success
end
test "should get new" do
get new_sch_url
assert_response :success
end
test "should create sch" do
... |
# @param {String} s
# @return {Integer}
def title_to_number(s)
title_number = 0
arr = s.each_char.to_a
arr.each do |n|
title_number = title_number * 26 + n.ord - 64
end
return title_number
end
cols = ["A", "B", "C", "D", "AA", "AB"]
cols.each {|s| puts title_to_number(s) }
|
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
get "games/:id/field", to: 'games#field'
put "games/:id/reset_timer", to: 'games#reset_timer'
resources :games
end
|
# frozen_string_literal: true
require 'test_helper'
module Vedeu
module Coercers
describe VerticalAlignment do
let(:described) { Vedeu::Coercers::VerticalAlignment }
let(:instance) { described.new(_value) }
let(:_value) {}
describe '#validate' do
subject { instance.valida... |
require 'rails_helper'
feature 'Start Complete Buttons', js: true do
context 'User visits appointment with no start date or completed_date' do
scenario 'and sees the start button is active and the complete button disabled' do
given_i_am_viewing_an_appointment
then_i_should_see_the_start_button
... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :null_session
include Authenticable
private
def current_user
@current_user
end
end
|
class AddOauthExp < ActiveRecord::Migration
def change
remove_column :users, :oath_expires_at
add_column :users, :oauth_expires_at, :datetime
end
end
|
#!/usr/bin/ruby
f_baseline = open ARGV[0]
f_in = open ARGV[1]
topk = ARGV[2].to_i
dataset = ARGV[3]
target = ARGV[4]
index_size = ARGV[5]
semantics = ARGV[6]
scoring = ARGV[7]
# load the baseline
baseline = {}
while not f_baseline.eof
line=f_baseline.readline.chomp.strip
next if line == ''
tokens = line.split(... |
xml.instruct! :xml, :version => '1.0'
xml.rss "version" => "2.0" do
xml.channel do
xml.title "R3PL4Y suggestions"
xml.description "R3PL4Y game description suggestions"
xml.link url_for(:controller => "suggestions", :action => "index")
@suggestions.each do |suggestion|
xml.item do
xml.title "#{... |
Rails.application.routes.draw do
devise_for :users, controllers: { sessions: 'sessions', registrations: 'registrations' }
root to: 'pages#welcome'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
authenticate :user do
resources :users, except: [] do
... |
require_relative '../feature_helper.rb'
feature 'Add comment', %q{
In order to express my opinion on record
As a user
I want to be able to leave comments on questions and answers
} do
given!(:user) { create(:user) }
given!(:question) { create(:question, user: user) }
given!(:answer) { create(:answer, question: q... |
#require 'byebug'
# ====== program 1 ======
# puts "diplay back counting\n"
# puts "enter a number:"
# s = gets.to_i
# loop do
# # byebug
# s -= 1
# puts s
# break if s <=1
# end
#@@@same program with short method@@@@
# x = gets.chomp.to_i
# until x < 0
# puts x
# x -= 1
# end
# ====== program 2 ======
# ... |
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "ueditor/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "ueditor.rails"
s.version = UEditor::VERSION
s.authors = ["Kaid Wong"]
s.email = ["kaid@kaid.me"]
... |
#
# Wowr - Ruby library for the World of Warcraft Armory
# http://wowr.rubyforge.org/
# Written by Ben Humphreys
# http://benhumphreys.co.uk/
#
# Author:: Ben Humphreys
# May not be used for commercial applications
#
begin
require 'hpricot' # version 0.6
rescue LoadError
require 'rubygems'
require 'hpricot'
end
... |
require File.expand_path(File.dirname(__FILE__) + "/../../../../spec_helper")
describe RepositoryGenerator do
it "repository template path" do
RepositoryGenerator.new("category", build_attributes).template_path.should == "src/templates/repositories"
end
context "JPA" do
before(:each) do
mock_... |
require_relative 'bike_container'
class Garage
include BikeContainer
DEFAULT_CAPACITY = 30
def initialize(options = {})
@capacity = options.fetch(:capacity, DEFAULT_CAPACITY)
@bikes = []
end
def repair
broken_bikes.each do |bike|
bike.fix!
self
end
end
def accept_broken_bikes_from(van)
van... |
require "spec_helper"
describe Concern::Methods::PublishingMethods do
describe "#publishing?" do
it "is true if status was changed and object is published" do
story = create :test_class_story, :pending
story.publishing?.should eq false
story.status = ContentBase::STATUS_LIVE
story.publis... |
конвертер
{command} (категория) ([число] [единица_измерения] [единица_измерения])
*/{command}
бот покажет список категорий конвертера
*/{command} temperature
бот покажет единицы измерения категории "temperature"
*/{command} distance 3 mile metre
бот переведет 3 мили в метры (4828) |
class CreateDonations < ActiveRecord::Migration
def change
create_table :donations do |t|
t.integer "certificate_id"
t.integer "amount_cents"
t.string "currency", :default => "USD", :null => false
t.timestamps
end
add_index :donations, :certificate_id
end
end
|
json.entries do
json.partial! 'api/v1/entries/show', collection: @entries, as: :entry
end
|
class CreateEventBabyPlans < ActiveRecord::Migration
def self.up
create_table :event_baby_plans do |t|
t.string :tags,:limit=>300
t.string :tag,:limit=>50
t.string :user_name,:limit=>50
t.integer :user_id
t.date :begin_at
t.date :end_at
t.datetime :start_at
t.dateti... |
#Interface class
class Interface
DEALER_PASS = 'Диллер пропускает ход'
DEALER_HIT = 'Диллер взял карту'
DRAW_MESSAGE = 'Ничья!'
WELCOME_MESSAGE = 'Добро пожаловать. Укажите ваше имя:'
def initialize
puts WELCOME_MESSAGE
end
def intro
gets.chomp.to_s
end
def welcome_message(to_whom)
p... |
require 'rails_helper'
feature 'Comments' do
before(:each) do
@user = create_user
@project = create_project
@membership = create_membership(project_id: @project.id, user_id: @user.id)
@task = create_task(project_id: @project.id)
end
def sign_in
visit root_path
click_on 'Sign In'
fill... |
require 'itpkg/utils/mysql_helper'
class Email::UsersController < ApplicationController
before_action :must_admin!
def index
@buttons = [
{label: t('links.email_user.create'), url: new_email_user_path, style: 'primary'},
{label: t('links.email'), url: email_path, style: 'warning'},
]
... |
require 'rails_helper'
RSpec.describe 'routes', type: :routing do
it { expect(get('/')) .to route_to 'candidates#index' }
it { expect(get('/candidates')).to route_to 'candidates#index' }
it { expect(post('/update_status/57/interview')).to route_to 'candidates#update_status', candidate_id: '57', status:... |
require "results"
class ResultsController < ApplicationController
class InvalidParameters < StandardError
def initialize(errors, message = nil)
@message = message
@errors = errors
end
attr_reader :errors
def message
@message || "Invalid parameters : #{errors}"
end
end
de... |
class Ship
attr_accessor :known_direction, :coords
def initialize(start_coords)
if (start_coords.flatten.count==2)
@coords = [start_coords.flatten]
else
@coords = start_coords
end
@known_direction = nil
end
def find_adjacent(state)
if @known_direction == :horizontal
retur... |
require 'spec_helper'
describe ROM::Container do
include_context 'users and tasks'
before do
setup.relation(:users) do
def by_name(name)
restrict(name: name).project(:name)
end
end
setup.relation(:tasks)
setup.commands(:users) do
define(:create)
end
setup.comma... |
class Driver
class Index < Trailblazer::Operation
step Nested(::Driver::New)
step TrailblazerHelpers::Steps::Driver::SetupDrivers
step :order_drivers
def order_drivers(options, **)
options['drivers'].order!(created_at: :desc)
end
end
end
|
require 'test_helper'
describe Cask::DSL do
it "lets you set url, homepage, and version" do
test_cask = Cask.load('basic-cask')
test_cask.url.to_s.must_equal 'http://example.com/TestCask.dmg'
test_cask.homepage.must_equal 'http://example.com/'
test_cask.version.must_equal '1.2.3'
end
it "lets yo... |
class Api::FollowsController < ApplicationController
before_action only: :destroy do |c|
c.prevent_illegal_changes params[:id]
end
before_action :redirect_unless_logged_in
def create
@follow = current_user.out_follows.new(follow_params)
if @follow.save
render json: @follow
else
rend... |
class PhysicianAddress < ApplicationRecord
belongs_to :physician
belongs_to :address
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.