text stringlengths 10 2.61M |
|---|
##
# 05 - Project Euler
#
# 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
#
# What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
def is_divisible(num)
if num % 1 == 0 &&
num % 2 == 0 &&
num % 3 == 0... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :article do
title 'test_title'
body 'test_body'
pv 0
trait :has_comments do
after(:create) do |article, evaluate|
create_list(:comment, 1, article: article)
end
end
end
end... |
require 'server'
require "test_helper"
class ServerTest < MiniTest::Spec
include Rack::Test::Methods
def app
Sinatra::Application.new
end
def setup
@redis = Redis.new
@redis.flushall
@board = Leaderboard.new("game")
1.upto(15) do |i| @board["user#{i}"] = 100-i end
end
describe :inde... |
class Group < ActiveRecord::Base
belongs_to :creator, :class_name => "User", :foreign_key => "creator_id"
has_many :memberships, :class_name => "GroupMembership", :dependent => :destroy
has_many :members, :through => :memberships, :uniq => true
has_many :group_scenarios, :d... |
require_relative '../views/sessions_view'
class SessionsController
def initialize(employee_repository)
@employee_repository = employee_repository
@view = SessionsView.new
end
def sign_in
# Lógica de autenticação
username = @view.ask_for('username')
password = @view.ask_for('password')
... |
module OutboundMessages
class << self
def welcome_message
"Welcome to Cuphon! Reply with STOP to stop. Reply HELP for help. Msg & data rates may apply. Max 3 msgs/week per brand. Visit Cuphon.com to learn more!"
end
def brand_too_long_message
"Welcome to Cuphon.com. Please make sure merchant n... |
class Exporter::ComplaintsOfficers < Exporter::Exporter
def column_definitions
column("ia_number") { record.complaint.ia_number }
column("case_number") { record.complaint.case_number }
column("incident_type") { record.complaint.incident_type }
column("received_date") { record.complaint.received_date }... |
class SignUp < ActiveRecord::Base
has_secure_password
validates_confirmation_of :password
validates_uniqueness_of :email
has_one :set_lifts
end
|
module Main
class ProductSpecifications < DataObjects
class Type
attr_reader :product_type
def initialize(product_type)
@data = {
paintings: {
attribute_groups_definitions_using_instance_names: {
list: [:artist, :year],
for_visitor: [:artist, ... |
require 'test_helper'
module Nls
module FeedInit
class TestInitErrors < NlsTestCommon
def setup
# override setup because this test do not need nls to be started
resetDir
end
def test_syntax_error
cp_import_fixture("package_with_error.json")
exception = a... |
require_relative '../tests/test_helper'
require 'calmotron/song'
require 'calmotron/track'
require 'midilib'
class SongTest < MiniTest::Test
def test_attributes
valid_key_song = Song.new('A')
assert_equal(valid_key_song.key, 'A')
#Invalid keys default to C
invalid_key_song = Song.new('Q')
assert... |
# 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 applicable law or agreed ... |
module Smtp
class Message < String
DEFAULT_CONTENT_TRANSFER_ENCODING = ContentTransferEncoding.new(
ContentTransferEncoding::EIGHT_BIT
)
def initialize(value, content_type = ContentType.new(ContentType::HTML))
super "#{value}\n"
@content_type = content_type
end
def as_part_of_sm... |
class VideosController < ApplicationController
before_action :ensure_admin!
before_action :set_video, only: [:edit, :update, :destroy]
def new
@video = Video.new
@trail_id = params[:id]
end
def edit
end
def create
@video = Video.new(video_params)
@trail = Trail.find(@video.trail_id)
... |
class User < ActiveRecord::Base
has_secure_password
validates :email, presence: true
scope :for, ->(activity) do
joins(:permissions).where(permissions: { action: "view",
thing_type: "Activity",
thing_id: activity.id })
... |
#
# Copyright (C) 2015 Red Hat, Inc.
#
# Author: Martin Magr <mmagr@redhat.com>
#
# 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 re... |
class FontNotoSans < Formula
head "https://noto-website-2.storage.googleapis.com/pkgs/NotoSans-unhinted.zip", verified: "noto-website-2.storage.googleapis.com/"
desc "Noto Sans"
homepage "https://www.google.com/get/noto/#sans-lgc"
def install
(share/"fonts").install "NotoSans-Black.ttf"
(share/"fonts").... |
class Review < ActiveRecord::Base
belongs_to :video
belongs_to :user
validates :message, presence: true
validates :rating, presence: true,
inclusion: (0..5).to_a
end
|
require 'test_helper'
class ProfilePicTest < ActiveSupport::TestCase
setup do
@profile = profiles(:dragon_profile_1)
@pic = profile_pics(:dragon_profile_pic_1)
@file_path = File.join(Rails.root, 'test', 'fixtures', 'files', 'Chimera-240.jpg')
end
test "make default" do
image = Rack::Test::Uploa... |
# frozen_string_literal: true
require 'selenium-webdriver'
require 'rspec'
require 'sauce_whisk'
Before do |scenario|
url = 'https://ondemand.us-west-1.saucelabs.com:443/wd/hub'
SauceWhisk.data_center = :US_WEST
if ENV['PLATFORM_NAME'] == 'linux' # Then Headless
url = 'https://ondemand.us-east-1.saucelabs.... |
FactoryGirl.define do
factory :user do
uid { rand(1...3).to_s }
screen_name { '@' + Faker::Lorem.word }
token { Faker::Crypto.md5 }
secret { Faker::Crypto.md5 }
end
end
|
require 'test_helper'
class CrimeFilesControllerTest < ActionDispatch::IntegrationTest
setup do
@crime_file = crime_files(:one)
end
test "should get index" do
get crime_files_url
assert_response :success
end
test "should get new" do
get new_crime_file_url
assert_response :success
end
... |
# = sckey.rb
#
# Description:: Straddling Checkerboard key
# Author:: Ollivier Robert <roberto@keltia.net>
# Copyright:: © 2001-2013 by Ollivier Robert
#
# $Id: sckey.rb,v 215f60fa1e7f 2013/03/10 17:52:14 roberto $
require 'key/skey'
module Key
# == SCKey
#
# class for straddling checkerboard substitution keys
... |
class AddSaveToAction < ActiveRecord::Migration
def change
add_column :actions, :save_attr, :string
end
end
|
require "test_helper"
describe Vote do
before do
@new_user = User.create!(username: "Mochi Cat")
@new_work = Work.create!(
category: "book",
title: "Harry Potter",
creator: "JK Rowling",
publication_year: 1990,
description: "great book"
)
@new_vote = Vo... |
class News < ApplicationRecord
belongs_to :admin, optional: true
attr_accessor :body
def read_file(file_path)
self.body = File.open("#{Rails.root}/public/#{file_path}", 'r'){ |f| f.read }
end
end |
module Forem
class Post < ActiveRecord::Base
include Workflow
include Forem::Concerns::NilUser
workflow_column :state
workflow do
state :pending_review do
event :spam, :transitions_to => :spam
event :approve, :transitions_to => :approved
end
state :spam
stat... |
class CompanyAdmin < ApplicationRecord
has_many :projects
has_many :employees
attr_accessor :presence_password
has_secure_password validations: false
validates :password, presence: true , if: :presence_password
has_secure_token
validates :username, presence: true , length: { maximum: 15 }, uniqueness... |
# Create table sections
class CreateSections < ActiveRecord::Migration[5.1]
# Create table
def change
create_table :sections do |t|
t.string :name
t.string :initials
t.integer :status
t.text :observation
t.integer :kind
t.timestamps
end
end
end
|
# -*- encoding : utf-8 -*-
class ChmailsController < ApplicationController
layout 'admin'
before_filter :confirm_logged_in
before_filter :confirm_priveleges_admin
def index
@chmails = Chmail.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @chmails }
... |
class OldRelation < ActiveRecord::Base
include ConsistencyValidations
set_table_name 'relations'
belongs_to :changeset
validates_associated :changeset
def self.from_relation(relation)
old_relation = OldRelation.new
old_relation.visible = relation.visible
old_relation.changeset_id = relatio... |
class FavoritesController < ApplicationController
before_action :set_book
def create
favorite = @book.favorites.new(user_id: current_user.id)
favorite.save
end
def destroy
favorite = current_user.favorites.find_by(book_id: @book.id)
favorite.destroy
end
private
def set_book
@book = Book.... |
require 'rails_helper'
RSpec.feature 'Changing employee state' do
before do
@admin = create(:admin)
login_as(@admin, scope: :admin)
end
scenario 'by activing him' do
@employee = create(:employee, state: 0)
visit admin_employees_path
expect(page).to have_content(@employee.full_name)
expe... |
class ArtistsController < ApplicationController
before_action :set_artist, only: [:show, :update]
# GET /artists
# GET /artists.json
def index
@artists = Artist.paginate(page: params[:page], per_page:6)
end
# GET /artists/1
# GET /artists/1.json
def show
@concerts = @artist.concerts.paginate(p... |
class Curso < ActiveRecord::Base
self.primary_key = :id_curso
belongs_to :category, :class_name => 'Category', :foreign_key => :id_categoria
has_many :dispositivos, :class_name => 'Dispositivo', :foreign_key => :id_curso
has_many :facilitador_has_cursos, :class_name => 'FacilitadorHasCurso'
has_ma... |
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# email :string(255) default(""), not null
# encrypted_password :string(255) default(""), not null
# reset_password_token :string(255)
# reset_password_sent_at :datetime... |
class Listing < ApplicationRecord
belongs_to :product
belongs_to :store, dependent: :destroy
before_validation :format_price_string
validates :price, presence: true
def format_price_string
self.price = price.gsub('$', '').strip #code from my old CSV
end
end
|
xml.urlset(xmlns: 'http://www.sitemaps.org/schemas/sitemap/0.9') do
xml.url do
xml.loc root_url
xml.changefreq('hourly')
xml.priority '1.0'
end
end
|
class CreateOrders < ActiveRecord::Migration
def change
create_table :order do |t|
t.integer :total, :precision => 10, :scale => 2
end
end
end
|
module Task::Print
def self.step(text)
puts "#{time_log} " + Rainbow(text).white
end
def self.substep(text)
puts "#{time_log} " + Rainbow(" #{text}").white
end
def self.notice(text)
puts "#{time_log} " + Rainbow(text).yellow
end
def self.warning(text)
puts "#{time_log} " + Rainbow(text... |
class Gossip < ApplicationRecord
belongs_to :user
has_many :taggossips, dependent: :destroy
has_many :tags, through: :taggossips
has_many :coms, dependent: :destroy
has_many :likes, dependent: :destroy
validates :title, :content, presence: true
validates :title, length: { minimum: 3, maximum: 14 }
e... |
class User < ActiveRecord::Base
acts_as_authentic
attr_protected :role
def after_initialize
if self.role.blank?
extend Role::User
else
extend "Role::#{self.role.classify}".constantize
end
end
def to_param
login
end
def self.from_param!(param)
find_by_login!(para... |
# frozen_string_literal: true
module WasteExemptionsShared
module EnrollmentsHelper
def submit_button_text(enrollment)
if enrollment.declaration?
t("global.accept_declaration")
elsif enrollment.choosing_exemption?
t("global.choosing_exemption_continue")
else
t("global.co... |
require "delegate"
module SpecRunner
class ClojurePath < SimpleDelegator
def exists?
File.exists?(self)
end
def points_to_spec_file?
!!match(/_spec.clj|_test.clj/)
end
def to_implementation
new { gsub(/_spec.clj|_test.clj/, ".clj") }
end
def in_implementation_director... |
json.array!(@guests) do |guest|
json.extract! guest, :id, :last_name, :first_name, :address, :email, :phone_number, :reception, :nijikai
json.url guest_url(guest, format: :json)
end
|
require 'minitest/autorun'
require_relative '../fightergame.rb'
class TestFighterGame < Minitest::Test
def setup
@player = {
name: "player 1",
wins: 0
}
@player_stats = {
type: 0,
health: 0,
strength: 0,
toughness: 0,
speed: 0
}
@opponent = {
... |
require 'rails_helper'
RSpec.describe CourseHole, type: :model do
it { should belong_to(:course) }
it { should validate_presence_of(:course) }
it { should validate_presence_of(:hole_number) }
it { should validate_presence_of(:yardage) }
it { should validate_presence_of(:par) }
end
|
# Question 2
# Question 2
# Alan created the following code to keep track of items for a shopping cart application he's writing:
# class InvoiceEntry
# attr_reader :quantity, :product_name
# def initialize(product_name, number_purchased)
# @quantity = number_purchased
# @product_name = product_name
# e... |
class SaveRoom
prepend SimpleCommand
# Update Room info
# form_object: UpdateRoomInfoForm
def initialize(form_object)
@form_object = form_object
end
def call
save_record(@form_object)
end
private
def save_record(form_object)
raise ArgumentError, 'Invalid RoomId' if form_object.id.nil?
... |
# encoding: UTF-8
module CDI
module V1
module Users
module AuthProviders
class Facebook
attr_reader :access_token, :options, :auth_provider_data, :errors, :existent_user
PROVIDER_ATTRIBUTES = [:email, :first_name, :last_name, :gender, :birthday, :about]
def initiali... |
# frozen_string_literal: true
module Hanamimastery
module CLI
module Commands
class Unshot < Dry::CLI::Command
desc 'Removes shot marks from a given article (i.e. ""[🎬 01] ")'
argument :episode, type: :integer, required: true, desc: "Episodes ID to unshot"
include Deps[
... |
class Employee < ActiveRecord::Base
belongs_to :store
validates :store, presence: true
validates :first_name, :last_name, :hourly_rate, presence: true
validates :hourly_rate, numericality: {:greater_than_or_equal_to => 20, :less_than_or_equal_to => 200}
end
|
require_relative 'CasinoEngine'
require_relative 'PokerHandEvaluator'
class AiRule
RULE_TYPE_JOKER = 0;
RULE_TYPE_HAND_OF_VALUE = 1;
RULE_TYPE_SAME_SUIT = 2;
RULE_TYPE_SAME_VALUE = 3;
RULE_TYPE_RUN_OF_LENGTH = 4;
AI_ACTION_KEEP_AND_CONTINUE = 0;
AI_ACTION_KEEP_AND_STOP = 1;
def initialize(myRuleType, myCount... |
class Admin::PerformancesController < Admin::BaseAdminController
load_and_authorize_resource
skip_load_resource
before_action :set_performance, except: %i[index compare employee_performance]
before_action :set_employee
before_action :ensure_same_employee, only: :employee_performance
before_action :set_perfo... |
Rails.application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
#root to: redirect(subdomain: 'transport', path: 'opentransport')
root to: redirec... |
module Omnimutant
class FileMutator
def initialize(filepath:, verbose:0)
@filepath = filepath
@file_original_data = File.read(@filepath)
@total_lines = @file_original_data.lines.size
@current_line_number = 0
@current_mutation_number = -1
@verbose = verbose
end
def d... |
class Item
include DataMapper::Resource
include DataMapper::MassAssignmentSecurity
property 'id', Serial
property 'title', String, required: true
property 'url', Text, lazy: false, required: true
property 'image_url', Text, lazy: false
property 'score', Integer, default: 0
property 'notes', Text
t... |
# U2.W6: Create a Car Class from User Stories
# I worked on this challenge by myself.
# 2. Pseudocode
# => Create an object class Car with model and color attributes, initialize with 0 speed
# => Create a method to set destination distance
# => Create a method to change car speed
# => Create a method to check car s... |
class ApplicationController < ActionController::Base
protect_from_forgery
helper_method :current_user
rescue_from CanCan::AccessDenied do |exception|
redirect_to root_url , alert: "Sorry mate that's not allowed!"
end
def current_user
begin
@current_user ||= User.find(session[:user_id]) if ses... |
class Post < ApplicationRecord
belongs_to :user
belongs_to :location
has_many :comments, dependent: :destroy
has_many :likes, dependent: :destroy
# def username
# self.user.username
# end
def likes_count
self.likes.length
end
def comments_count
self.comments.length
end
def destinat... |
def caesar_cipher(string, num)
cipher = ""
string.each_char do |ch|
ch = ch.ord
if ch.between?(97, 122) || ch.between?(65, 90)
ch += (num % 26)
elsif ch > 122 || ch.between?(90, 97)
ch -= (num % 26)
end
ch = ch.chr
cipher << ch
end
... |
# rubocop:disable Style/FrozenStringLiteralComment
WINNING_LINES = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] + # rows
[[1, 4, 7], [2, 5, 8], [3, 6, 9]] + # cols
[[1, 5, 9], [3, 5, 7]] # diagonals
# rubocop:enable Style/FrozenStringLiteralComment
INITIAL_MARKER = ' '.freeze
PLAYER_MARKER = 'X'.f... |
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'nytimes_congress/version'
Gem::Specification.new do |spec|
spec.name = "nytimes_congress"
spec.version = NytimesCongress::VERSION
spec.authors = ["Eric Candino"]
spec... |
Rails.application.routes.draw do
devise_for :customer,
path: :customers,
:controllers => {
:registrations => "customer/registrations",
:sessions => "customer/sessions",
:passwords => "customer/passwords"
}
devise_for :admin,
path: :admins,
:controllers => {
:sessions =>... |
module Datamappify
module Data
module Criteria
module Relational
class FindMultiple < Common
alias_method :entity_class, :entity
attr_reader :primaries, :secondaries, :structured_criteria
def initialize(*args)
super
@primaries = []
... |
# frozen_string_literal: true
module ActiveAny
class AssociationRelation < Relation
def initialize(klass, association)
super(klass)
@association = association
end
def proxy_association
@association
end
def ==(other)
other == records
end
private
def exec_que... |
#!/usr/bin/env ruby
require "rubygems"
###
# http client tools
# Url/fetching/curl like stuff
#
class HttpClient
##
# Stub for future use...
end
##
# Openuri/wget combo version
class SimpleHttpClient < HttpClient
require "open-uri"
def easy_download ( url, path )
system("wget", "-q", "-O", ... |
class SessionsController < ApplicationController
skip_before_action :require_login, only: [:create]
def create
auth_hash = request.env['omniauth.auth']
merchant = Merchant.find_by(uid: auth_hash[:uid], provider: 'github')
if merchant
# flash[:status] = :success
# flash[:result_text] = "Lo... |
require 'stk_env'
class Stk_sequence
@@obj_map = {}
def initialize(env,name,id,sequence_type,service_type,options,ref=nil)
if ref == nil
@_seq = Stksequence.stk_create_sequence(env.ref(),name,id,sequence_type,service_type,options);
else
@_seq = ref;
end
@_env = env
@_id = Stksequence.stk_get_sequence... |
class CreateAddresses < ActiveRecord::Migration[5.2]
def change
create_table :addresses do |t|
t.integer :user_id, null: false
t.string :first_name, null: false
t.string :last_name, null: false
t.string :first_kana_name, null: false
t.string :last_kana_name, null: false
t.strin... |
# frozen_string_literal: true
class User < ApplicationRecord
class MismatchedPassword < StandardError; end
include PgSearch::Model
include Concerns::Chapterable
include Concerns::Searchable
ALLOWABLE_FLAGS = %w[mod_manager logistics].freeze
attr_accessor :bypass_create_characters_hook
validates :last... |
class Comedian < ApplicationRecord
validates_presence_of :name, :city
validates :age, presence: true, numericality: {
only_integer: true,
}
has_many :specials
def self.average_age
Comedian.average(:age).round(0).to_i
end
def self.cities
Comedian.distinct.pluck(:city)
end
end
|
class Configuration
attr_accessor :api_key, :urlname
end
|
class CreateCompanies < ActiveRecord::Migration
def change
create_table :companies do |t|
t.string :name, null: false
t.string :subdomain, null: false
t.string :domain, null: false
t.string :logo
t.string :address_1
t.string :address_2
t.string :city
t.string :count... |
class AddDealtToCards < ActiveRecord::Migration
def change
add_column :cards, :dealt, :boolean
end
end
|
xml.instruct!
xml.rss "version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
xml.channel do
xml.title "Padrino Blog"
xml.description "The fantastic padrino sample blog"
xml.link url_for(:posts, :index)
for post in @posts
xml.item do
... |
require "csv"
require "awesome_print"
# class that creates an instance of an order
class Order
# creates methods that will allow reading or writing of specified instance variables
attr_reader :id, :products, :customer, :fulfillment_status
attr_writer :fulfillment_status
# constructor that sets up each instan... |
require 'rails_helper'
describe ContestantPresenter do
let(:target) { double id: 42, name: 'John Doe', avatar_path: '/path/to/avatar' }
let(:contestant) { ContestantPresenter.new target }
describe 'id' do
it 'returns the target id' do
expect(contestant.id).to eq 42
end
end
describe 'name' do
... |
class ChangeBookings < ActiveRecord::Migration
def change
change_table :bookings do |t|
t.remove :passenger_id
end
change_table :passengers do |t|
t.references :booking_id
end
end
end
|
$lines = IO.readlines('input.txt')
def possible_bin_combinations(length)
combinations = []
for i in 0..2**length - 1 do
combination = i.to_s(2)
if combination.length < length
combination = "#{zeros_string(length - combination.length)}#{combination}"
end
combinations ... |
class Api::TaskListsController < Api::BaseController
#before_action :check_owner, only: [:show, :update, :destroy]
def index
# page = params[:page].to_i
# page_size = params[:page_size].to_i
task_lists = TaskList.all
# binding.pry
#task_lists = TaskList.paginate(:page => params[:page],... |
class Exectest < ApplicationRecord
belongs_to :qa
belongs_to :suite
belongs_to :teste
end
|
require 'rails_helper'
RSpec.describe "Menus", type: :system do
describe "menus/index" do
let!(:user) { create :user }
let!(:admin) { create :admin }
let!(:menu) { create :menu }
let!(:menu_second) { create :menu_second }
let!(:menu_third) { create :menu_third }
context "user" do
bef... |
# frozen_string_literal: true
require 'saml/user_attributes/id_me'
require 'saml/user_attributes/mhv'
require 'saml/user_attributes/dslogon'
require 'sentry_logging'
require 'base64'
module SAML
class User
include SentryLogging
attr_reader :saml_response, :saml_attributes, :user_attributes
def initial... |
require 'pry'
class Artist
attr_reader :name
@@all = []
def self.all
@@all
end
def initialize(name)
@name = name
@@all << self
end
def new_song(name, genre)
Song.new(name,self,genre)
end
#helper
def songs
Song.all.select do |song_instance|
song_instance.artist == se... |
# frozen_string_literal: true
class ImagesController < ActionController::Base
PUBLIC_MOUNTS = {
'User' => :image,
}
def show
http_cache_forever(public: true) do
model_name = params[:model_name]
attribute_name = PUBLIC_MOUNTS[model_name]
head(:not_authorized) and return unless attribute... |
class Cache
class << self
###
### Retrieving Information from the Cache
###
# Returns the current patch version
def get_patch
Rails.cache.read(:patch)
end
# @collection_key the plural collection identifier such as champions, items
# Returns a hash of all collection names mapped... |
class RenameRequestColumnToJobAdministrations < ActiveRecord::Migration[5.0]
def change
rename_column :blogs, :tweet_id, :user_id
end
end
|
# Command Pattern
class Command
attr_reader :description
def initialize(description)
@description = description
puts @description
end
def execute
end
end
class CreateFile < Command
def initialize(path, contents)
super "Create file: #{path}"
@path = path
@contents = contents
end
d... |
class User < ActiveRecord::Base
has_many :groups
has_many :items, through: :groups
end |
class LogsController < ApplicationController
def new
@ticket = Ticket.find(params[:ticket_id])
@log = @ticket.logs.new
end
def create
@log = Log.create(log_params)
if @log.valid?
@log.save!
flash[:notice] = "New ticket log saved sucessfully"
redirect_to tickets_path
else
... |
PointlessFeedback.setup do |config|
# ==> Feedback Configuration
# Configure the topics for the user to choose from on the feedback form
# config.message_topics = ['Error on page', 'Feature Request', 'Praise', 'Other']
# ==> Email Configuration
# Configure feedback email properties (disabled by default)
# ... |
require 'spec_helper'
feature 'Deleting activities' do
before do
sign_in_as!(FactoryGirl.create(:admin_user))
end
scenario 'Deleting an activity' do
FactoryGirl.create(:activity, name:'Student Project')
visit '/'
click_link 'Student Project'
click_link 'Delete Activity'
expect(page).... |
# frozen_string_literal: true
# Road class
class Road
attr_accessor :point_a, :point_b
def initialize(point_a, point_b)
@point_a = point_a
@point_b = point_b
end
end
|
class Status < ActiveRecord::Base
belongs_to :user, inverse_of: :statuses
belongs_to :task, inverse_of: :statuses
default_scope -> { order('created_at DESC') }
validates :content, presence: true
validates :user_id, presence: true
end
|
require './statcollector.rb'
require 'psych'
describe "The StatConfiguration class" do
before(:all) do
@fullconfig = Psych.load('
name: myproject
location: /a/location/for/myproject
max: 10
one_per_day: true
decending: true
output: csv
collect:
command1: "a command"
command2: another command
')
@partialconfig ... |
class SlackCommentDecoratorService
attr_accessor :github_comment, :subscription
def initialize(github_comment)
@github_comment = github_comment
@subscription = ''
end
def title
case github_comment.state
when 'approved'
approve_comment
when 'changes_requested'
@subscription = co... |
module Inventory
class SeedCatalogue
prepend SimpleCommand
def initialize(args = {})
@args = args
end
def call
seed_raw_material_catalogue!
seed_plant_catalogue!
seed_sales_catalogue!
seed_non_sales_catalogue!
nil
end
private
def seed_raw_material_ca... |
require './key'
require 'twitter'
client = Twitter::REST::Client.new do |config|
config.consumer_key = CONSUMER_KEY
config.consumer_secret = CONSUMER_SECRET
config.access_token = ACCESS_TOKEN
config.access_token_secret = ACCESS_TOKEN_SECRET
end
#ツイートする
client.update("Test tweet from twitter-api with r... |
require "rails_helper"
describe Dashboard::BlocksController do
let!(:user) { create(:user) }
let!(:register) { @controller.send(:auto_login, user) }
let!(:block) { create(:block, user: user) }
describe "PUT #set_as_current" do
before { put :set_as_current, id: block.id }
it { is_expected.to redirect_t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.