text stringlengths 10 2.61M |
|---|
class StudentsController < ApplicationController
def create
# raise params.inspect
@student=Student.new(student_params)
if @student.save
render 'show'
else
render 'new'
end
end
def show
@student=Student.find(params[:id])
end
def new
@student=Student.new
end
def index
@students=Student.a... |
class AddWorkExperienceToJob < ActiveRecord::Migration[5.2]
def change
add_column :jobs, :work_experience, :string
end
end
|
require 'rails_helper'
RSpec.describe SessionsController, type: :controller do
let(:user) { FactoryGirl.create(:user) }
describe "GET #index" do
it "returns http success" do
get :index
expect(response).to have_http_status(:success)
end
end
describe "GET #create" do
context 'successfull... |
class CreatePersonneInScenes < ActiveRecord::Migration
def change
create_table :personne_in_scenes do |t|
t.integer :id_scene
t.integer :id_personne
t.timestamps
end
add_index :personne_in_scenes, :id_scene
add_index :personne_in_scenes, :id_personne
add_index :personne_in_scen... |
# encoding: utf-8
# Copyright 2014 Square Inc.
#
# 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 applic... |
class LinksController < ApplicationController
before_filter :get_link, except: [:index, :new, :create]
before_filter :require_user, except: [:index, :show]
before_filter :require_moderator_or_own_link, only: [:edit, :update]
before_filter :require_admin_or_own_link, only: [:destroy]
# GET /links
# GET /lin... |
namespace :artwork do
desc "Revome underscores in Artwork titles and replace with blank space."
task :fix_titles => :environment do
art = Artwork.all
art.each do |p|
oldtitle = p.title
p.update_column(:title, new_title(p.title))
puts "#{oldtitle} -> #{p.title}"
end
end
def new_tit... |
# frozen_string_literal: true
class Tournament < ApplicationRecord
after_save :minimum_players_abort, if: :saved_change_to_start_date?
after_update :achievement, if: :saved_change_to_winner_id?
after_touch :lone_participant_winner, if: :lone_participant?
validates :start_date, presence: true
validates :time... |
ActiveAdmin.register Comment do
# See permitted parameters documentation:
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
# permit_params :list, :of, :attributes, :on, :model
#
# or
#
permit_params do
permitted = [:commentor_name, :commentor_ac... |
require 'spec_helper'
describe User do
TWITTER_RESPONSE = {"provider"=>"twitter",
"uid"=>"54321",
"info"=> {"nickname"=>"Tmock12"},
"credentials" => { "token" => "1234", "secret" => "4321" },
"extra" => { "raw_info" => { "time_z... |
# Generated by jeweler
# DO NOT EDIT THIS FILE
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{active_url}
s.version = "0.1.4"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_ver... |
require 'rails_helper'
RSpec.describe Api::V1::MessagesController, type: :request do
describe 'POST /api/v1/messages' do
context 'with valid parameters' do
it 'creates a Message object' do
valid_params = {
recipient: 'abbey',
sender: 'corey',
body: 'a short message'
... |
class Market::ProductProperty < ActiveRecord::Base
belongs_to :product, class_name: '::Market::Product', inverse_of: :product_properties
belongs_to :property, class_name: '::Market::Property', inverse_of: :product_properties
def property_name
property.try(:name)
end
def property_name=(name)
# no-o... |
#!/usr/bin/env ruby
# this is mostly a "bookmark" cause I keep forgetting the command
# for this - so this script will remember for me :)
if ARGV[0] == nil
raise 'First argument must be a file path to file which to generate a checksum for.'
else
puts "Generating checksum for #{ARGV[0]}"
end
puts `md5 "#{ARGV[0]}... |
class KnightPathFinder
attr_accessor :position, :moves
attr_reader :tree
def initialize(position)
@position = position
@tree = PolyTreeNode.new(position)
@visited_positions = [position]
build_move_tree
end
def self.valid_moves(position)
valid_moves = []
offsets = [
[1, 2... |
class Api::V1::AlbumsController < ApplicationController
before_action :load_album, only: [:songs]
def songs
render json: build_response(@album.songs, SongSerializer)
end
private
def load_album
@album = Album.find_by(id: params[:id])
end
end
|
#{
# "token" : {
# "variables" : {
# "command_" : [
# "timer",
# 1465632809
# ],
# },
# "childs" : [],
# "node" : "state_a",
# "uuid" : "584a115e-26ac-412e-b466-e0853527b088"
# }
#}
require 'json'
require 'open3'
require 'stringio'
require 'net/http'
... |
FactoryGirl.define do
factory :av_link do
assoc_id 0
volunteer_id 0
rights { rights }
level { level }
end
end
|
class AddPlaylistColumnToPlaylistItems < ActiveRecord::Migration[5.0]
def change
add_column :playlist_items, :playlist_id, :integer
add_index :playlist_items, :playlist_id
end
end
|
# -*- coding: utf-8 -*-
MindpinSidebar::Base.config do
# example
#
# rule :admin do
# nav :students, :name => '学生', :url => '/admin/students' do
# controller :'admin/students'
# subnav :student_info, :name => '学生信息', :url => '/admin/students/info' do
# controller :'admin/student_i... |
class RemoveStarsFromRestaurants < ActiveRecord::Migration
def change
remove_column :restaurants, :stars, :string
end
end
|
class Article < ApplicationRecord
belongs_to :user
validates :title, presence: true, length: { minimum: 3, maximum: 50 }
validates :description, presence: true, length: { minimum: 10, maximum: 10000 }
validates :user_id, presence: true
has_many :comments, dependent: :destroy
# dependent: :dest... |
# encoding: utf-8
module Ktl
class Reassigner
attr_reader :limit
def initialize(zk_client, options={})
@zk_client = zk_client
@limit = options[:limit]
@overflow_path = '/ktl/overflow'
@state_path = '/ktl/reassign'
@logger = options[:logger] || NullLogger.new
@log_assignm... |
class AddAnswerLogToTorves < ActiveRecord::Migration[5.1]
def change
add_column :torves, :answer_log, :boolean, default: false, null: false
end
end
|
class Game < ActiveRecord::Base
#returns true if a game has been confirmed by either loser
def confirmed?
self.confirmed
end
# checks if points have been transferred, after transfer this is set to true
# and points won't be transferred again
@transferred = false
#confirms game
def confirm
sel... |
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# name :string
# email :string
# login :string
# created_at :datetime not null
# updated_at :datetime not null
# password_digest :string
# remember_d... |
module Shopify
def self.table_name_prefix
'shopify_'
end
end
|
class AddDevelopmentToAmenity < ActiveRecord::Migration
def change
add_column :amenities, :development_id, :integer
end
end
|
class Reply < ApplicationRecord
belongs_to :comment
belongs_to :user
has_many :reports
validates :description, presence: true
validates_associated :comment, presence: true
end
|
module Sentry
module Transports
class Transport
attr_accessor :configuration
def initialize(configuration)
@configuration = configuration
end
def send_event # (auth_header, data, options = {})
raise NotImplementedError, 'Abstract method not implemented'
end
end
... |
# encoding: utf-8
require_relative '../../spec_helper'
# For Ruby < 1.9.3, use this instead of require_relative
# require (File.expand_path('./../../../spec_helper', __FILE__))
describe Enrico::VacationDay do
describe "default instance attributes" do
it "test initializer methods" do
beginning_of_year = Da... |
require "spec_helper"
describe Notifier do
context "comment_updated" do
let!(:activity) { FactoryGirl.create(:activity) }
let!(:folder_owner) { FactoryGirl.create(:user) }
let!(:folder) { FactoryGirl.create(:folder, activity: activity,
user: folder_owner) }
let!(:... |
class Nokogiri::XML::Node
LS_SHORT = "node()"
LS_LONG_START = "[.='"
LS_LONG_END = "']"
def ls(opts = {})
@exp_long_content ||= self.name
if opts[:long]
return yellow(self.class::LS_SHORT) +
self.class::LS_LONG_START +
magenta(@exp_long_content) +
self.class::LS_LONG_END
... |
require 'rails_helper'
RSpec.describe UsersController, type: :controller do
sign_in!(:visitor)
describe 'GET #settings' do
it 'assigns current user as @user' do
get :settings
expect(assigns :user).to eql subject.current_user
end
end
describe 'PUT #update_password' do
let(:valid_params... |
require 'rails_helper'
describe 'valid user can sign in' do
before :each do
visit root_url
click_on "Sign Up"
end
it "successfully adds a user" do
expect(page).to have_content 'Hard Knocks'
fill_in "User name", with: "Puggeroni"
fill_in "About", with: "Dog"
fill_in "Password", with: "pa... |
class Villager
#? There are many different attributes a villager MAY have I would like to know if there would be
#? a way to create additional attribute accessors for this class in my second scrape, the way that I figured all of these
#? were potential attributes was by doing the second scrape and adding at... |
class Dashboard::ProxiesController < AuthenticatedController
def index
@proxies = current_user.proxies.all
end
def new
@proxy = Proxy.new
end
def create
@proxy = Proxy.new(proxy_params)
@proxy.user = current_user
if @proxy.save
redirect_to dashboard_proxies_path, notice: 'Proxy cr... |
class CreditCardCharge < ActiveRecord::Base
belongs_to :customer
scope :successful, -> {where(paid:true, refunded:true)}
scope :failed, -> {where(paid:false, refunded:false)}
scope :disputed, -> {where(paid:true, refunded:false)}
end
|
class FixColumnName < ActiveRecord::Migration
def change
rename_column :heros, :descritpion, :description
end
end
|
class Person
def initialize(name, age)
@name = name
@age = age
end
#getter
def getName
return @name
end
def getAge
return @age
end
#setter
def setName(name)
@name = name
end
def setAge
@age = 12
end
end
puts "Whats your name?"
userName = gets.chomp
john = Person.new("J... |
class CreatePlayerStats < ActiveRecord::Migration
def change
create_table :player_stats do |t|
t.integer :player_id
t.integer :game_id
t.float :total_time_alive
t.datetime :time_dead
t.float :kill_rate_by_day
t.integer :number_of_kills
t.integer :rank_died_at
t.time... |
# frozen_string_literal: true
require 'jiji/test/data_builder'
module Jiji::Test::Mock
class MockSecurities < Jiji::Model::Securities::VirtualSecurities
include Jiji::Errors
include Jiji::Model::Trading
include Jiji::Model::Securities::Internal::Virtual
attr_reader :config
attr_writer :pairs
... |
class KnightPathFinder
MOVES = [
[-2, -1],
[-2, 1],
[-1, -2],
[-1, 2],
[ 1, -2],
[ 1, 2],
[ 2, -1],
[ 2, 1]
]
def self.valid_moves(pos)
valids = [] #valid moves go here
x,y = pos #our current posistion
# will need... |
require 'spec_helper'
describe Following do
let (:follower) { User.make }
let (:following) { User.make :username => "bob", :email => "bob@wut.com" }
it "should validates uniqueness of follower and following" do
Following.create(:follower => follower, :following => following)
lambda {Following.create(:... |
class CreateUploadDocuments < ActiveRecord::Migration
def change
create_table :upload_documents do |t|
# 关联 upload_document_dirs 表 ID
t.integer :dir_id
t.string :title
# ['TEXT', 'WORD', 'EXCEL']
t.string :category
t.text :content
t.integer :file_entity_id
t.... |
# -*- coding: utf-8 -*-
require 'benchmark'
module T3Config
BOARD_MAX_INDEX = 2
BOARD_DIM = BOARD_MAX_INDEX + 1
BOARD_LEN = BOARD_DIM * BOARD_DIM
PLAYERS = { -1 => 'X', 1 => 'O', 0 => ' ' }
COMPUTER_PLAYER = -1
HUMAN_PLAYER = 1
EMPTY_POS = 0
def self.t3_corners
[[0, 0], [0, BOARD_MAX_INDEX], [BOAR... |
class RenameFollowing < ActiveRecord::Migration
def change
rename_table(:followerings, :followings)
end
end
|
require 'rake/gempackagetask'
$dir = File.dirname(__FILE__)
task :default => :spec
desc "Run all unit tests"
task :test do
tests = FileList["#{$dir}/test/*_test.rb"]
tests.each {|t| require t}
end
desc "Run all specs"
task :spec do
system('spec', '-c', "#{$dir}/spec")
end
namespace "migrate" do
desc "Run th... |
require "rack"
require "rack/server"
class FirstApp
def self.call(env)
seed = ("a".."z").to_a.sample
[200, {}, ["Hello World #{seed}"]]
end
end
Rack::Server.start app: FirstApp
|
config_dir = File.join(ENV['HOME'], '/.ssh')
mkdir_p config_dir do
owner ENV['SUDO_USER'] || node['current_user']
end
execute 'ensure current user owns the ssh folder' do
command "chown -R #{ENV['SUDO_USER'] || node['current_user']} #{config_dir}"
end
|
control "M-7.9" do
title "7.9 Ensure CA certificates are rotated as appropriate (Not Scored)"
desc "
Rotate root CA certificates as appropriate.
Docker Swarm uses mutual TLS for clustering operations amongst its nodes.
Certificate
rotation ensures that in an event such as compromised node or key, it is... |
class AddShowFieldsToProject < ActiveRecord::Migration[5.0]
def change
add_column :projects, :first_spec, :text
add_column :projects, :second_spec, :text
add_column :projects, :third_spec, :text
add_column :projects, :pitch, :string
end
end
|
module Requests
module PushGet
Promise = Struct.new(:status, :headers, :body)
def test_push_get
assets_dir = Dir.mktmpdir("test_assets")
File.open(File.join(assets_dir, "main.css"), "w+") { |f| f.write(".rule {}") }
server.run do |req, rep|
if req.url == "/"
rep.body = ... |
require 'rails_helper'
RSpec.describe TeamInvitation, type: :model do
subject { build :team_invitation }
it { is_expected.to validate_presence_of :team }
it { is_expected.to validate_presence_of :token }
it { is_expected.to validate_inclusion_of(:accepted).in_array([true, false]) }
it { is_expected.to belong... |
class ShareholderBillsController < ApplicationController
before_filter :authenticate_user!
load_and_authorize_resource :account
load_and_authorize_resource :shareholder_bill, :through => :account
# GET /shareholder_bills/1
def show
end
# GET /shareholder_bills/new
def new
@shareholder = current_u... |
class NewPlayerFields < ActiveRecord::Migration
def self.up
add_column :players, :jersey_number, :integer
add_column :players, :birth_date, :date
add_column :players, :nationality, :string
add_column :players, :previous_club, :string
end
def self.down
remove_column :players, :jersey_number
... |
#===========================================================================
# Animated Battlebacks (VX)
# by jmoresca
# July 18,2009
#
# Ported to RMVXA
# by DrDhoom
# May 20, 2013
#===========================================================================
#
# How to use:
# Just configure the AnimBB modu... |
class FontSyneTactile < Formula
head "https://github.com/google/fonts/raw/main/ofl/synetactile/SyneTactile-Regular.ttf", verified: "github.com/google/fonts/"
desc "Syne Tactile"
desc "Originally designed for the Art Center 'Synesthésie'"
homepage "https://fonts.google.com/specimen/Syne+Tactile"
def install
... |
class AddAddressToMember < ActiveRecord::Migration[6.0]
def change
add_column :members, :address, :json
end
end
|
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
config.vm.box =... |
class User < ApplicationRecord
has_many :questions
validates :username, uniqueness: true
has_secure_password
def token
JWT.encode({ user_id: self.id }, ENV['RAILS_SECRET'])
end
def self.decode_token(token)
payload = JWT.decode(token, ENV['RAILS_SECRET'])[0]
self.find(payload[... |
FactoryBot.define do
factory :complaint_officer do
complaint
officer
factory :complaint_officer_kirk do
name { "James T. Kirk" }
title { "Cpt." }
badge { 4242 }
allegation { "Piracy" }
finding { "Sustained" }
finding_date { "2061-06-29" }
action_taken { ["Floggin... |
class WeatherController < ApplicationController
def by_zip
data = client.call :get_city_forecast_by_zip, message: { "ZIP" => params[:zip] }
data = data.body[:get_city_forecast_by_zip_response][:get_city_forecast_by_zip_result]
forecast = data.delete(:forecast_result)[:forecast].first rescue {}
data[:... |
module Api
module V1
class AlbumsController < Api::V1::ApiController
before_action :set_category, only: :index
before_action :set_artist, only: :index
before_action :set_album, only: :show
def index
@albums =
if @category
@category.albums.order_year_dsc
... |
# frozen_string_literal: true
# Copyright (c) 2017-present, BigCommerce Pty. Ltd. All rights reserved
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction, including without l... |
#require 'spec_helper'
require "rails_helper"
describe Api::V1::ApiController, type: :controller do
before do
class Dummy
def initialize(data = nil) end
def save!() true end
def errors() return [1] end
def update(attrs = nil) true end
def destroy() true end
def self.human_att... |
require 'spec_helper'
describe "affiliations/new" do
before(:each) do
theStubModel = stub_model(Affiliation,
:name => "MyString",
:location => nil,
:social_info => nil
).as_new_record
theStubModel.build_location
theStubModel.build_social_info
assign(:affiliation, theStubModel)
... |
class Analysis < ActiveRecord::Base
has_one :analysis_data,:dependent => :destroy
has_attached_file :image,
:whiny => false,
:styles => { :thumb => ["72x72>"], :main => ["200x200>"] }
validates_presence_of :name, :message => 'should be present.'
validates_attachment... |
#
# To enable/disable replication peers
#
if (node["bcpc"]["hadoop"]["hbase"]["repl"]["enabled"])
bash "create_hbase_repl_peer" do
code <<-EOH
echo "add_peer '#{node["bcpc"]["hadoop"]["hbase"]["repl"]["peer_id"]}','#{node["bcpc"]["hadoop"]["hbase"]["repl"]["target"]}'"|hbase shell
EOH
not_if "echo... |
class CreateMovies < ActiveRecord::Migration[5.2]
def change
create_table :movies do |t|
t.string :title
t.string :director
t.string :production
t.string :genre
t.string :movie_type
t.integer :year
t.string :link
t.text :synopsis
t.text :casting
t.text :... |
class Owner::LyricsController < ApplicationController
before_action :authenticate_user!
def index
@lyrics = Lyric.all
@lyrics = Lyric.order("title").page(params[:page]).per_page(6)
end
def new
@lyric = Lyric.new
end
def create
lyric_create_params = lyric_params
lyric_create_params["... |
class AddTripIdToPermissions < ActiveRecord::Migration
def change
add_column :permissions, :trip_id, :integer
end
end
|
module OrientdbBinary
module BaseProtocol
class ConfigSet < BinData::Record
include OrientdbBinary::BaseProtocol::Base
endian :big
int8 :operation, value: OrientdbBinary::OperationTypes::REQUEST_CONFIG_SET
int32 :session
protocol_string :config_key
protocol_string :config_v... |
require 'rails_helper'
describe 'weather api' do
it 'can send an image of a city' do
json_response = File.read('spec/fixtures/denver_unsplash_data.json')
stub_request(:get, "https://api.unsplash.com/search/photos?client_id=#{ENV['UNSPLASH_KEY']}&per_page=1&query=denver,co").
to_return(status: 200, body... |
json.array!(@tickets) do |ticket|
json.extract! ticket, :id, :id, :subject, :message, :is_active, :is_read, :user_id, :status, :numbering
json.url ticket_url(ticket, format: :json)
end
|
# encoding: utf-8
# !/usr/bin/env ruby
class Login < SitePrism::Page
set_url "https://the-internet.herokuapp.com/login"
element :username_field, "input[id='username']"
element :password_field, "input[id='password']"
element :login_button, "button[class='fa fa-2x fa-sign-in']"
element :data_alert, "div[id='f... |
require 'mittsu'
require_relative 'shapes/cube.rb'
require 'pry-remote'
require 'ast'
require 'byebug'
require 'wit'
# Monkey patching Object like it's the golden old days
class Object
def recursive_find(method_name, &find_condition_block)
if find_condition_block.call(self)
return self
end
if... |
class GardenHealthSerializer
include FastJsonapi::ObjectSerializer
attributes :id, :reading_type, :reading, :created_at
end
|
# view.rb
# generic definition of a view
require 'module.rb'
View = Struct.new(:name, :modules, :trusted, :data, :critical, :assumptions,
:protected, :ctx)
class View
def findMod s
(modules.select { |m| m.name == s })[0]
end
def findData s
(data.select { |d| d.name == s})[0]
end
... |
Rails.application.routes.draw do
resources :drinks
root "drinks#index"
end
|
# frozen_string_literal: true
module Api
module V1
class UsersController < ApiController
def update
user = User.find(updata_params[:id])
user.image = updata_params[:image]
render json: user.save ? 'OK' : 'NG'
end
def image
user = User.find(params[:id])
i... |
FactoryBot.define do
factory :user do
first_name { Faker::Name.first_name }
last_name { Faker::Name.last_name }
email { Faker::Internet.email }
password { "password" }
password_confirmation { "password" }
is_active { true }
user_mode { "admin" }
trait :worker do
user_mode { "wor... |
class RecapsController < ApplicationController
before_action :set_event, only: [:new, :edit, :create, :update]
before_action :set_recap, only: [:edit, :update]
def index
redirect_to(events_path)
end
def show
redirect_to(events_path)
end
def new
if current_user.nil?
flash[:warning] = "... |
require 'rails_helper'
RSpec.describe Itinerary, :type => :model do
it "responds to name" do
expect(Itinerary.new).to respond_to(:name)
end
it "requires name" do
expect(Itinerary.new(start_date: "2015-02-14", end_date: "2015-02-17", description: "Hello")).to be_invalid
end
it "requires start_date... |
require 'json'
require 'active_model'
# Define constant for earth's radius in km
R = 6371
class Person
include ActiveModel::Validations
attr_accessor :id, :value, :company, :email, :address, :country
attr_reader :name, :location
validates_presence_of :id, :value, :name, :location, :company, :email, :address,... |
class UserOrder
def initialize(session, params)
@session = session
@params = params
end
def create_order
@order = Order.create(user_id: @session[:user_id],
card_number: @params[:order][:card_number],
card_expiration: @params[:order][:card_expiration... |
namespace :db do
desc "load process data from csv"
task :load_process_data, [:csv_file] => :environment do |t , args|
puts "input file is #{args.csv_file}"
if args.csv_file.size == 0
puts "missing input file name"
exit
end
counter = 0
FasterCSV.foreach(args[:csv_file],:col_sep => ... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :cancelled_order, :class => 'CancelledOrders' do
cancelled false
cancelled_at "2015-07-06 10:06:28"
cancel_reason "MyString"
order_id 1
location "MyString"
price 1
end
end
|
class DevicesController < ApplicationController
before_action :set_device, only: [:show, :log, :update, :destroy]
before_action :set_app, only: [:create, :update]
def index
@devices = @user.devices.includes(:app).all
end
def show
end
def create
@device = @user.devices.new(device_params)
@de... |
# frozen_string_literal: true
module Api::V1::Subscriptions::Cancel
class CreateAction < ::Api::V1::BaseAction
CUSTOMERIO_EVENT_TRIAL = 'free-trial-cancelled'
CUSTOMERIO_EVENT_ACTIVE = 'active-cancelled'
try :find, catch: Sequel::NoMatchingRow
step :authorize
tee :enqueue_jobs
step :cancel
... |
require 'spec_helper'
describe Hutch::Serializers::JSON do
let(:subject) { described_class }
it "encode/decode" do
payload = { a: 1, b: 2 }
encoded = subject.encode(payload)
decoded = subject.decode(encoded)
expect(encoded).to eq "{\"a\":1,\"b\":2}"
expect(decoded).to eq("a" => 1, "b" => 2)
... |
class Score
include DataMapper::Resource
property :id, Serial
property :name, String
property :level, String
property :score, String
end
|
When(/^i visit the login page$/) do
visit '/login'
end
When(/^i fill in my email and password$/) do
fill_in("Email", :with => 'seller@example.com')
fill_in("Password", :with => 'password')
click_button("Sign in")
end
Then(/^I login successfully$/) do
expect(page).to have_content('Signed in successfully.')
e... |
class PaymentType < ActiveRecord::Base
belongs_to :order
def self.names
all.collect {|pt| pt.name }
end
end
|
class Tweet < ApplicationRecord
belongs_to :user, optional: true
has_many :tweet_tags
has_many :tags, through: :tweet_tags
before_validation :link_check, on: :create
validates :message, presence: true
validates :message, length: {maximum: 140, too_long: "A tweet is only 140 max"}, on: :create
after_... |
module Mongoid::Slug::Criterion
# Override Mongoid's finder to use slug or id
def for_ids(*ids)
return super unless @klass.ancestors.include?(Mongoid::Slug)
# We definitely don't want to rescue at the same level we call super above -
# that would risk applying our slug behavior to non-slug objects, in ... |
module ApplicationHelper
include SubjectsHelper
include BootstrapHelper
include AceEditorHelper
include BindHelper
include SearchHelper
include WindowHelper
include UploadHelper
include Select2Helper
include SettingsHelper
include MinusPlusButtonHelper
def avatar_url(user)
user.image || ident... |
# 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... |
class BookingsController < ApplicationController
# GET /bookings
# GET /bookings.xml
before_filter :find_project
def index
@bookings = Booking.find(:all,:conditions=>["project_id = ? ",params[:project_id]])
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @b... |
require 'rails_helper'
RSpec.describe 'Merchant Items API' do
before(:all) do
@merchants = create_list(:merchant, 2)
@merchants.first.items << create_list(:item, 5, merchant: @merchants.first)
end
it 'returns merchant items' do
id = @merchants[0].id
items = @merchants[0].items
get "/api/v1/m... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.