text stringlengths 10 2.61M |
|---|
class AffiliateProgram < ActiveRecord::Base
belongs_to :affiliate
belongs_to :email_list, :dependent => :destroy
belongs_to :reputable_badge, :class_name => "Reputable::Badge", :foreign_key => "badge_id"
has_one :review_requirement, :dependent => :destroy
has_many :affiliate_users
has_many :users, :th... |
json.array!(@utility_charges) do |utility_charge|
json.extract! utility_charge, :id, :utility_name, :utility_charge, :utility_charge_date, :property_id
json.url utility_charge_url(utility_charge, format: :json)
end
|
class Api::V1::LikesController < ApplicationController
def create
entry = Entry.find(params[:entry_id])
like = entry.likes.build(like_params)
if like.valid?
entry.save
render :json => LikeSerializer.new(like), status: :accepted
else
#error messa... |
require 'rails_helper'
RSpec.describe Document, type: :model do
it 'has a valid factory' do
expect(build(:document)).to be_valid
end
describe 'ActiveModel validations' do
it 'requires a sendType' do
expect(build(:document, name: nil)).not_to be_valid
end
end
end
|
class AuditsController < ApplicationController
before_filter :authenticate_user!
respond_to :html
def index
@audits = current_user.audits
end
def new
@audit = current_user.audits.build
end
def create
@audit = current_user.audits.new(audit_params)
if @audit.save
redirect_to edit_a... |
# frozen_string_literal: true
# rubocop:todo all
# Copyright (C) 2014-2020 MongoDB 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
#
# U... |
# Author: Stephen Sykes
# http://pennysmalls.com
require 'rubygems'
require 'active_record'
require 'active_record/version'
require File.dirname(__FILE__) + '/../lib/slim_attributes'
require 'test/unit'
require File.dirname(__FILE__) + "/products"
require File.dirname(__FILE__) + "/slim_db_test_utils"
class SlimAttri... |
module WebexApi
class WebexError < StandardError
attr_reader :data
def initialize(data)
@data = data
super
end
end
class ConnectionError < StandardError; end
class NotFound < StandardError; end
end |
class Coin
attr_accessor :symbol, :USD, :EUR
def initialize(symbol, usd, eur)
@symbol, @usd, @eur = symbol, usd, eur
end
end |
require 'rails_helper'
RSpec.describe 'Client navigate', type: :system do
before { log_in }
describe 'from index page' do
it 'goes to view' do
client_create human_ref: 111
visit '/clients/'
first('.link-view-testing', visible: false).click
expect(page).to have_text '111'
expect... |
require "cells"
module Trailblazer
class Cell < ::Cell::ViewModel
abstract!
self.view_paths = ["app/concepts"]
# TODO: this should be in Helper or something. this should be the only entry point from controller/view.
class << self
def class_from_cell_name(name)
name.camelize.constantize... |
# frozen_string_literal: true
class ActivityPresenter
attr_reader :activity
def initialize(id: 1)
@activity = Activity.find(id)
end
end
|
Pod::Spec.new do |s|
s.name = "NAlamofire"
s.version = "2.0.11"
s.summary = "NAlamofire is wrapper of Alamofire - it makes use Alamofire easiest way."
s.homepage = "http://cornerteam.com"
s.license = "MIT"
s.author = "Nghia Nguyen"
s.platform = :ios, "9.0"
s.ios.depl... |
require "rails_helper"
RSpec.describe Product, :type => :model do
it { should validate_presence_of(:title) }
it { should validate_presence_of(:description) }
it { should validate_numericality_of(:price).is_greater_than(0) }
it 'title is shorter than description' do
product = Product.create(title: 'ruby book', ... |
class Appointment < ApplicationRecord
has_many :results, dependent: :destroy
belongs_to :user
belongs_to :provider
end
|
class AddRepIdToLink < ActiveRecord::Migration
def change
add_column :links, :rep_id, :integer
end
end
|
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
# Copyright (C) 2016 Yusuke Suzuki <yusuke.suzuki@sslab.ics.keio.ac.jp>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the ... |
class CreateDescripcioncortes < ActiveRecord::Migration
def change
create_table :descripcioncortes do |t|
t.integer :tallacantidad
t.integer :capas
t.string :color
t.integer :tallaxs
t.integer :tallas
t.integer :tallam
t.integer :tallal
t.integer :tallaxl
t.re... |
require 'rails_helper'
describe 'User visits /programs' do
scenario 'They see that program\'s information and all gov purchases' do
program = Program.create!(name: 'Denver Police Department')
program2 = Program.create!(name: 'City Treasury')
program3 = Program.create!(name: 'Parks and Rec')
program4 ... |
class SaveItemsController < ApplicationController
before_action :authorized
def create
library = params[:library]
image = params[:image]
if image["data"]
item = Item.find_or_create_by(
category: "nasalibrary",
api_id: image["data"][0]["nasa_id"],
media_url: image["hre... |
class LineItemsController < ApplicationController
before_action :load_table, only: [:new, :edit, :index, :show]
before_action :load_line_item, only: [:edit, :create, :show, :destroy]
def new
end
def edit
render 'new'
end
def index
end
def create
if params[:find]
@datum= LineItem.fin... |
require 'rails_helper'
RSpec.describe Contact, type: :model do
describe "relationships" do
it "belongs to a company" do
contact = Contact.new(full_name: "Steve Jobs", position: "CEO", email: "steve@me.com")
expect(contact).to respond_to(:company)
end
end
end
|
module Contentr
class ContentPage < Page
# Protect attributes from mass assignment
permitted_attributes :layout
# Validations
validates_presence_of :layout
end
end
|
require_relative 'player'
require_relative 'population'
class Game
attr_reader :chosen_hero, :population, :logger
def initialize(logger:)
# hash sort by score ascending
@population = Population.new(logger: logger)
@logger = logger
end
def update(world, data)
world ||= World.new
world.eve... |
# A class that given a phrase can count the occurrences
# of each word in that phrase
class Phrase
def initialize(phrase)
@phrase = phrase
end
def word_count
count_hsh = Hash.new(0)
@phrase.scan(/\b[\w']+\b/) do |match|
count_hsh[match.downcase] += 1
end
count_hsh
end
end
|
class CreateSailUsers < ActiveRecord::Migration
def self.up
create_table "sail_users" do |t|
t.column :portal_id, :integer
t.column :portal_token, :string
t.column :first_name, :string, :limit => 60
t.column :last_name, :string, :limit => 60
t.column :uuid, :string, :limit => 36
... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe TicketType, type: :model do
describe '#validations' do
subject { build(:ticket_type) }
it { is_expected.to validate_presence_of(:price) }
it { is_expected.to validate_presence_of(:name) }
end
describe '#associations' do
it { i... |
class Order < ActiveRecord::Base
belongs_to :user
has_many :order_staches
has_many :staches, through: :order_staches
before_create :set_ordered_status
validates :zipcode, presence: true, length: { is: 5 }, numericality: true
validates :first_name, presence: true
validates :last_name, presence: true
val... |
require File.dirname(__FILE__) + '/../../test_helper'
require 'ostruct'
class ApplicationHelperTest < ActionView::TestCase
SEARS_SID = '?sid=comm_sears_productpg'
KMART_SID = '?sid=comm_kmart_productpg'
#== SEARS_SEARCH_FOR_IT_URL ==#
test '#sears_search_for_it_url should include the category keywor... |
# Assignment: Project
# Create a Project Class that has the following attributes: name, description. Also, create a instance method called elevator_pitch that will print out the name of the project and its description separated by a comma.
# class Project
# # your code here
# end
# project1 = Project.new("Project 1"... |
# frozen_string_literal: true
module Smashcut
RSpec.describe Screenplay do
# TODO(#shipit): decide if this is main public interface
describe "::from_fountain" do
context "when it succeeds" do
it "parses and transforms the fountain input" do
screenplay = described_class.from_fountain("H... |
class ChangeOptionToChoice < ActiveRecord::Migration[5.1]
def change
rename_table :options, :choices
end
end
|
require_relative 'child_process'
require_relative '../option'
module Media
module Command
class Converter
attr_accessor :options, :inputs, :outputs
def initialize(args={}, &block)
@options = Array args.fetch(:options, [])
@inputs = Array args.fetch(:inputs, [])
@outputs = ... |
class FreemarkerTemplateEngine < VraptorScaffold::Base
def self.source_root
File.join(File.dirname(__FILE__), "templates", "freemarker")
end
def initialize(project_path, options)
super
self.destination_root=(project_path)
@project_path = project_path
@options = options
end
def configure... |
@posts = Post.order_by([:created_at, :desc]).page(1)
{
I18n: {
default_locale: I18n.default_locale,
locale: I18n.locale
},
posts: render_bootstrap_data('posts/index')
}
|
class Shoe < ApplicationRecord
belongs_to :buyer, class_name: 'Profile', foreign_key: "buyer_id", optional: true
belongs_to :seller, class_name: 'Profile', foreign_key: "seller_id"
has_many_attached :pictures
end
|
# frozen_string_literal: true
Sequel.migration do
change do
create_table(:games) do
primary_key :id
column :description, :text
column :created_at, 'timestamp with time zone'
column :updated_at, 'timestamp with time zone'
foreign_key :line_up_1_id, :line_ups,
ty... |
class CreatePeriods < ActiveRecord::Migration
def change
create_table :periods do |t|
t.string :number
t.date :starting_date
t.date :ending_date
t.timestamp :created_on
end
end
end
|
class RenameMyColumnByCustomersLocations < ActiveRecord::Migration
def up
rename_column :customers_locations, :suspend, :status
end
def down
end
end
|
module OnlineKramdown
class App < Sinatra::Base
# Configure reloading.
configure do
register Sinatra::Reloader if development?
end
# Configure logging.
configure do
STDOUT.sync = true
enable :logging unless test?
end
# Enable static serving.
configure do
set ... |
class User < ApplicationRecord
before_save :save_validate
belongs_to :role
has_one :authenticate, dependent: :destroy
has_many :careers, dependent: :destroy
validates_presence_of :name
validates_presence_of :lastname
validates_presence_of :patronymic
#validates_presence_of :login
#va... |
module Jievro
module Tools
module Converter
class HexadecimalFloatStringToFloatConverter
def convert(hexadecimal_float_string)
fail Exception, 'Cannot convert non `String\' values' \
unless hexadecimal_float_string.is_a?(String)
clean_string = hexadecimal_float_strin... |
class Phone < ActiveRecord::Base
has_many :carriers, through: :phones_carriers
has_many :phones_carriers
has_many :carriers, through: :phones_carriers
end
|
# frozen_string_literal: true
require 'rails_helper'
describe 'GET /api/admin/actors', autodoc: true do
let!(:actor1) { create(:actor) }
let!(:actor2) { create(:actor) }
context 'ログインしていない場合' do
it '401が返ってくること' do
get '/api/admin/actors'
expect(response.status).to eq 401
end
end
conte... |
if node['platform_version'].to_i >= 7
default['nginx']['amplify']['platform_version'] = 7
else
default['nginx']['amplify']['platform_version'] = 6
end
#Accepted values are default, custom
# use custom if you want to override the settings.
default['nginx']['amplify']['install_type'] = "default"
default['nginx'][... |
class ApiController < ApplicationController
respond_to :html, :json
#onboarding options for cors
def contact_form_options
#TODO verify originating domain
cors_set_access_control_headers
head :ok
end
#submit form
def contact_form_post
form = params[:form]
puts form
# submit the for... |
Rails.application.routes.draw do
root :to => 'events#index'
resources :events
end
|
# Compass + blueprint installer
# by Glenn Roberts
# based on
# Compass Ruby on Rails Installer (template) v.1.0
# written by Derek Perez (derek@derekperez.com)
# Source : http://github.com/chriseppstein/compass/raw/master/lib/compass/app_integration/rails/templates/compass-install-rails.rb
# --------------------------... |
class Item < ApplicationRecord
has_many :cartsitems
end
|
class BlogPostsController < ApplicationController
before_filter :admin_authorized?, :only => [:edit, :new, :update, :create]
def index
@blog_posts = BlogPost.find(:all, :order => 'created_at desc')
respond_to do |format|
format.html
format.xml
end
end
def show
@blog_pos... |
require 'active_support/concern'
module HexedSlugable
extend ActiveSupport::Concern
included do
extend FriendlyId
friendly_id :generated_slug, use: :slugged
end
def generated_slug
require 'securerandom'
SecureRandom.hex(16)
end
end
|
require 'ostruct'
class GetAwsJobsStatus < AwsRequest
attr_reader :jobs
def call
begin
vaults.each do |vault|
resp = glacier.list_jobs(
account_id: account_id,
vault_name: vault.name
)
# deal with paged response
self.jobs = resp.job_list.map{|job| Open... |
require 'pry'
class Dog
attr_accessor :name, :breed, :id
def initialize(name:, breed:, id: nil)
@name = name
@breed = breed
#@id = nil
end
def self.create_table
sql = <<-SQL
CREATE TABLE IF NOT EXISTS dogs (
id INTEGER PRIMARY KEY,
name TEXT,
breed TEXT)
SQL
DB[:conn].execute(sql)
end
def self.drop_table... |
class SessionsController < ApplicationController
skip_before_action :verify_authenticity_token, :only => :create
def login
end
def create
if logged_in?
@identity = Identity.update_with_omniauth(auth, current_user.id)
else
@identity = Identity.update_with_omniauth(auth)
log_in @identi... |
require 'minitest/autorun'
require 'sqlite3'
require 'pry'
DATABASE = SQLite3::Database.new("data_for_testing.db")
# require_relative 'db_setup.rb'
require_relative "category.rb"
require_relative "location.rb"
require_relative "product.rb"
class WarehouseTest < Minitest::Test
# def setup
# DATABASE.execute("DEL... |
class User < ApplicationRecord
has_many :liens
has_many :commentaries
has_many :comment_to_commentaries
end
|
describe Permutation do
it 'permutates a flat array' do
data = ["1", "2", "3"]
expected = [["1", "2", "3"]]
expect(Permutation.call(data).sort).to eq(expected.sort)
end
it 'permutates an array with single nested item' do
data = ["1", ["A", "B"]]
expected = [
["1", "A"],
["1", "B... |
require 'rails_helper'
RSpec.describe EPP::Response::Result, db: false do
# https://tools.ietf.org/html/rfc5730#section-3
describe '::codes' do
it 'returns codes' do
codes = {
'1000' => :success,
'1001' => :success_pending,
'1300' => :success_empty_queue,
'1301' => :succes... |
##
# Copyright 2017-2018 Bryan T. Meyers
#
# 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 applicable law or agreed to in w... |
def is_pandigital?(num)
num = num.to_s
first = num[0,9].split('')
first.delete("0")
return first.uniq.count == 9
end
pre_fib = 0
cur_fib = 1
new_fib = 0
i = 1
puts "Standard fibonacci accumulation"
# use standard fibonacci iteration to
# get a sufficiently... |
class UnsplashService
def connection
Faraday.new(url: "https://api.unsplash.com") do |f|
f.adapter Faraday.default_adapter
f.params['client_id'] = ENV['UNSPLASH_ACCESS_KEY']
end
end
def fetch_image(city, state)
response = connection.get("/photos/random?query=#{city},#{state}")
JSON.p... |
class RemoveTimeFromPayersAndAddTimeToTransactions < ActiveRecord::Migration[6.1]
def change
remove_column :payers, :time
add_column :transactions, :time, :datetime
end
end
|
class Booking < ApplicationRecord
BOOKINGS_PARAMS = [:price, :status, :checkin, :checkout, :bill_id, :room_id,
booking_services_attributes: [:id, :amount,
:service_id, :_destroy]].freeze
belongs_to :bill
belongs_to :room
has_many :booking_services, ... |
# frozen_string_literal: true
unless System::Database.oracle?
ThinkingSphinx::Index.define(:topic, with: :real_time) do
indexes :title
indexes sphinx_post_bodies, as: :post
has :tenant_id, type: :bigint
has :forum_id, type: :bigint
has :sticky, type: :boolean
has :last_updated_at, type: :ti... |
class CustomerNumbertoString < ActiveRecord::Migration[5.2]
def change
change_column :customers, :number, :string
end
end
|
require 'rails_helper'
RSpec.describe "camps/index", :type => :view do
before(:each) do
assign(:camps, [
Camp.create!(
:name => "Name",
:description => "Description",
:bitcoin_address => "Bitcoin Address"
),
Camp.create!(
:name => "Name",
:description => ... |
require_relative '../../test_helper'
class GraphTest < MiniTest::Unit::TestCase
def setup
@collection = 'tests'
@key = 'instance'
@kind = 'link'
@client, @stubs, @basic_auth = make_client_and_artifacts
@target_collection = 'bucket'
@target_key = 'vez'
end
def test_get_graph
body = { ... |
class RenameTableDecisionsGeneralYesNo < ActiveRecord::Migration
def self.up
rename_table "decisions_general_yes_no", "general_yes_no_decisions"
end
def self.down
end
end
|
require 'active_support/core_ext'
require 'forgetsy/set'
require 'forgetsy/delta'
require 'redis/namespace'
module Forgetsy
extend self
# Accepts:
# 1. A 'hostname:port' string
# 2. A 'hostname:port:db' string (to select the Redis db)
# 3. A 'hostname:port/namespace' string (to set the Redis namespa... |
# frozen_string_literal: true
ActiveAdmin.register Faq do
menu :priority => 12
config.sort_order = 'position_asc'
permit_params :questions, :answers, :id
controller do
def create
PaperTrail.enabled = false
super
PaperTrail.enabled = true
end
end
reorderable
# Reorderable Inde... |
require 'spec_helper'
require 'shared_contexts'
describe 'archive' do
context 'RHEL Puppet opensource' do
let(:facts) {{ :osfamily => 'RedHat', :puppetversion => '3.7.3' }}
it { should contain_package('faraday').with_provider('gem') }
it { should contain_package('faraday_middleware').with_provider('gem'... |
require 'spec_helper'
feature 'organization api management' do
let(:organization) { FactoryGirl.create(:organization) }
it 'returns an organization JSON' do
get "/api/v1/organizations/#{organization.slug}.json"
expect(response).to match_response_schema('organization')
end
end
|
require 'spec_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
... |
class AddDislikedByIdToDislikes < ActiveRecord::Migration
def change
add_column :dislikes, :disliked_by_id, :integer
end
end
|
# Author:: Sergio Fierens
# License:: MPL 1.1
# Project:: ai4r
# Url:: http://ai4r.org/
#
# You can redistribute it and/or modify it under the terms of
# the Mozilla Public License version 1.1 as published by the
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
module Ai4r
module Gene... |
Pod::Spec.new do |s|
s.name = "MMAppSwitcher"
s.version = "0.3.0"
s.summary = "Customize your card view in iOS8's app switcher (multitasking view)"
s.homepage = "https://github.com/venj/MMAppSwitcher/"
s.license = 'MIT'
s.author = { "vpdn" => "vp@dinhmail.de" }
s.sou... |
# frozen_string_literal: true
RSpec.describe Dry::Types::Map do
context "shared examples" do
let(:type) { Dry::Types::Map.new(::Hash) }
it_behaves_like "Dry::Types::Nominal#meta"
it_behaves_like Dry::Types::Nominal
it_behaves_like "a constrained type"
it_behaves_like "a composable constructor"
... |
class FournisseursController < ApplicationController
before_action :set_fournisseur, only: [:show, :edit, :update, :destroy]
# GET /fournisseurs
# GET /fournisseurs.json
def index
@fournisseurs = Fournisseur.all
end
# GET /fournisseurs/1
# GET /fournisseurs/1.json
def show
end
# GET /fourniss... |
#!/usr/bin/ruby
require 'prime'
def triangle_number n, current
current + n
end
need_primes = 10000
generator = Prime::EratosthenesGenerator.new
count = 0
primes = Array.new()
until count == need_primes do
count += 1
primes << generator.next
end
i = 1
divisors = 0
triangle_number = 0
while divisors < 500
p... |
class Discount < ActiveRecord::Base
has_many :products
validates :name,:discount_type, :quantity, presence: true
validates :name, uniqueness: true
enum discount_type: [:get_free, :price_reduce]
before_destroy :safe_to_delete
def safe_to_delete
if products.any?
return false
else
ret... |
require 'rails_helper'
RSpec.describe GymHistory, type: :model do
describe "belongs_to" do
it "'belongs_to' and 'hasmay' are connected collectly" do
g = Gym.create!(name: "hello", lat: 35, lng: 139)
expect {
g.histories.create!(team: 'y', time: Time.now, point: 2000)
}.not_to raise_erro... |
class Permission
include Mongoid::Document
has_one :view
embedded_in :role
end
|
namespace :ios do
namespace :carthage do
carthage_zip_file_name = 'carthage.tar.gz'
carthage_resolved_file_name = 'Cartfile.resolved'
carthage_folder_name = 'Carthage'
desc 'zipping'
task :zip, :src_folder, :output_folder do |_, args|
output_tar_path = File.join(args[:output_folder], carth... |
class Status < ActiveRecord::Base
attr_accessible :name, :ns
has_many :companies
scope :listing_status, where(:ns => 'listing_status')
end
|
module OnetableTerminator
module Structures
class Rule
attr_accessor :number, :vm_id, :nic, :raw_line, :io, :target
def initialize(line_hash)
@number = line_hash[:number]
@raw_line = line_hash[:raw_line]
@io = line_hash[:io]
@target = line_hash[:target]
@vm_id ... |
class Admin::VideosController < AdminsController
def new
@video = Video.new
end
def create
@video = Video.new(video_params)
if @video.save
flash[:success] = "You have created a new video, #{@video.title} "
redirect_to new_admin_videos_path
else
flash[:danger] = "There was a prob... |
require File.dirname(__FILE__) + '/../test_helper'
# have to extend the File object to support the content_type method that the server uses.
class File
attr_accessor :content_type, :original_filename, :local_path
end
class LocalPhotoTest < ActiveSupport::TestCase
fixtures :local_photos, :sources
de... |
class Parser
def initialize(locations, generation)
@locations = locations
@generation = generation
end
def result
if @locations.length < 1
[["No Alive Generation"]]
else
@generation.with_live_cells_at(@locations)
output_cells = @generation.draw_generation(StdOutCanvas.new)
... |
# frozen_string_literal: true
module BeyondCanvas
module ApplicationHelper # :nodoc:
def full_title(page_title = '')
base_title = BeyondCanvas.configuration.site_title
page_title.empty? ? base_title : page_title + ' | ' + base_title
end
def link_to_with_icon(name = nil, options = nil, fa_cl... |
module Lita
module Handlers
class Statuspage < Handler
route(
/^(?:statuspage|sp)\sincident\snew\s(.+)$/,
:incident_new,
command: true,
help: {
'(statuspage|sp) incident new name:"<name>"' => 'Create a new realtime incident',
' ... |
class RenameStocksTableStockColumnToStockYankId < ActiveRecord::Migration
def self.up
rename_column :stocks, :stock_id, :stock_yank_id
end
def self.down
rename_column :stocks, :stock_yank_id, :stock_id
end
end
|
class AdminUser
attr_accessor :first_name, :last_name
end
|
# frozen_string_literal: true
# Provides asynchronous purging of ActiveStorage::Blob records via ActiveStorage::Blob#purge_later.
class ActiveStorage::PurgeJob < ActiveStorage::BaseJob
# FIXME: Limit this to a custom ActiveStorage error
retry_on StandardError
def perform(blob)
blob.purge
end
end
|
# coding: utf-8
require 'optparse'
require 'sword'
require 'sword/patch'
module Sword::CLI
DEFAULTS = {:Port => 1111}
@options = []
class << self
def new(arguments = ARGV)
Sword::Patch.load
@settings = DEFAULTS
parser.parse!(arguments)
run! unless suicide?
end
def suicide?
... |
require 'spec_helper'
describe Spree::Chimpy do
context "enabled" do
before do
Spree::Chimpy::Interface::Lists.stub(new: :lists)
Spree::Chimpy::Interface::List.stub(new: :list)
Spree::Chimpy::Interface::Orders.stub(new: :orders)
config(key: '1234', lists: [{name: 'Members'}])
end
... |
class AdminUsersController < ApplicationController
before_action :your_admin_page, only:[:show]
def new
@admin_user = AdminUser.new
end
def create
@admin_user = AdminUser.new(admin_user_params)
if @admin_user.save
redirect_to admin_user_path(@admin_user.id), notice: "アカウント登録完了"
else
... |
require 'test_helper'
class AgentTest < ActiveSupport::TestCase
test "should not save agent without name" do
agent = Agent.new
agent.name = ''
assert_not agent.save, "Saved the agent without name"
end
test "should not save agent without email" do
agent = Agent.new
agent.email =''
ass... |
class ContactMailer < ApplicationMailer
def contact_email(params)
@name = params[:name]
self.mail({
to: "owner@example.com",
subject: "SiteContact"
})
end
end
|
module LemonadeStand
class Event
DAY_TYPES = [:sunny, :hot_and_dry, :cloudy]
def self.for day
type = DAY_TYPES.select { |x| day.weather.send("#{x}?".to_sym) }.first
send("#{type}_event_for".to_sym, day)
end
def self.sunny_event_for day
return build(:street_work) if day.number > 2... |
require 'rails_helper'
RSpec.describe AnswerNotificationService do
let(:question) { create(:question) }
let!(:answer) { create(:answer, question: question) }
context 'sends notification to subscribers' do
let!(:subscriptions) { create_list(:subscription, 2, question: question) }
it 'AnswerNotificationM... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.