text
stringlengths
10
2.61M
class Admin::ArtistsController < Admin::BaseController def index @artists = Artist.all end def show @artist = Artist.find(params[:id]) end def new @artist = Artist.new end def edit @artist = Artist.find(params[:id]) end def create @artist = Artist.new(artist_params) if @artist.save redirect_to admi...
class Project < ActiveRecord::Base belongs_to :users, :dependent => :destroy has_many :success_conditions, :dependent => :destroy accepts_nested_attributes_for :success_conditions, :allow_destroy => true def self.search(query) where("name LIKE ?", "#{query}") end end
class Like < ActiveRecord::Base include ActiveModel::Serialization belongs_to :user belongs_to :blank validates :user_id, :blank_id, presence: true end
require 'test_helper' require 'uri' class FilePushJsonPreviewTest < ActionDispatch::IntegrationTest include Devise::Test::IntegrationHelpers setup do Settings.enable_logins = true Settings.enable_file_pushes = true Rails.application.reload_routes! @luca = users(:luca) @luca.confirm end te...
require_relative 'spec_helper' describe 'Catalog Page' do let(:wait) { Selenium::WebDriver::Wait.new } context 'when iOS', platform: :ios do it 'can add backpack' do backpack = wait.until do @driver.find_element(class_chain: '**/XCUIElementTypeOther[`name == "store item" AND label CONTAINS "Bac...
require 'rails_helper' RSpec.describe DocumentsController, :type => :controller do let(:valid_attributes) { {name: 'phu'} } let(:invalid_attributes) { {name: ''} } context "logged-in users" do before(:each) do # @user = FactoryGirl.create(:user) @user = create(:user) ...
class Admin::UsersController < ApplicationController before_action :authenticate_admin! def index @users = User.all end def show @user = User.find(params[:id]) @likes = @user.likes @places = @user.places @locations = @user.locations end def update @post = Place.find(params[:id]) ...
class Article < ActiveRecord::Base attr_accessor :converuploads, :printeduploads, :innerpageuploads, :copyrightuploads #serialize :converavatars, Array # has_many :converavatars def self.search(query, page, page_size) query = query ? query.strip : nil if query && !query.empty? then query = "%#{query}%" ...
class UsersController < ApplicationController before_action :set_user, only: [:show, :edit, :update, :destroy] # TODO: redundant because of call from application controller? before_action :authenticate_user! def index @users = User.all end def show @friends = @user.friends.chronological_order ...
class Comment < ActiveRecord::Base belongs_to :commentable, polymorphic: true validates :content, presence: true validates :author_email, presence: true validates :author, presence: true end
require 'spec_helper' describe Graphlient::Client do describe 'parse and execute' do module Graphlient::Client::Spec Client = Graphlient::Client.new( 'http://graph.biz/graphql', headers: { 'Authorization' => 'Bearer 1231' }, allow_dynamic_queries: false ) do |client| c...
module Fappu class Connection attr_accessor :base_url, :title, :url, :documentation, :response, :body def initialize(settings={}) @base_url = settings[:base_url] || "https://api.fakku.net/index" # @response = RestClient.get @base_url @response = URI.parse(@base_url).read @body = J...
# == Schema Information # # Table name: movies # # id :integer not null, primary key # title :string # date_released :integer # description :text # created_at :datetime not null # updated_at :datetime not null # class Movie < ActiveRecord::Base validates_pres...
class CreateProperties < ActiveRecord::Migration def change create_table :properties do |t| t.string :addressLine1 t.string :addressLine2 t.string :town t.string :county t.string :postcode t.timestamps null: false end end end
FactoryBot.define do factory :asset do sequence :tag do |n| "300#{n}" end sequence :serial_number do |n| "601#{n}" end model { 'Dell Inspiron' } department { 'East Sussex' } department_id { 'LEA845' } department_sold_to_id { '80160000' } location { 'Juniper Street Sch...
require 'ruby-debug' Given /^I have a new contact whose email is "(.*?)"$/ do |email_address| @email_address = email_address end When /^I go to the page to add a contact for this client$/ do visit new_user_url(:client_id => @client.id, :subdomain => @user.client.account.subdomain) end # When /^I fill in and save...
class BaseResource < Webmachine::Resource def show @show ||= MODEL.find_show(CGI.unescape(request.path_info[:name])) end def options {'Allow' => allowed_methods.join(',')} end def trace? true end def params @params ||= Hash[URI.decode_www_form(request.body.to_s)] end end
FactoryGirl.define do factory :upload_file, class: UploadManager do filename "test1" description "upload for test" attachment_file_name "test" attachment_content_type "image/jpg" attachment_updated_at Time.now attachment_file_size 123 end factory :upload_file_without_file, class: UploadMa...
require 'stream_parser' class CookieStore::CookieParser include StreamParser NUMERICAL_TIMEZONE = /[-+]\d{4}\Z/ def parse cookie = {attributes: {}} @stack = [:cookie_name] while !eos? case @stack.last when :cookie_name scan_until(/\s*=\s*/) if match == '=' ...
#!/usr/bin/env ruby require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'chronos')) require 'trollop' require 'json' require 'terminal-table' ## Sub commands SUB_COMMANDS = %w[list delete delete_all start add] # TODO: delete_tasks add_dependency add_docker graph task] # list def subcmd_list(cmd_...
require "test_helper" class SuppliersControllerTest < ActionController::TestCase before do @supplier = Supplier.create :name => 'ICA', :phone => '555-687 558', :category => 'milk', :address => 'Fogdevagen 7a', :city => 'Karlskrona', :email => 'email@email.com' end it "should get index" do get :index ...
require 'rails_helper' describe PeriodicExpenseRunner, type: :model do let(:runner) { PeriodicExpenseRunner.new } context '#run_for_periodic_expense' do context 'with a periodic expense' do context 'that is ready to pay' do it 'creates an expense' do periodic_expense = create(:periodic...
module GarbageCollection DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 1.0).to_f @@last_gc_run = Time.now @@reserved_ivars = %w(@loaded_fixtures @test_passed @fixture_cache @method_name @_assertion_wrapped @_result) def scrub_instance_variables (instance_variables - @@reserved_ivars).each do |ivar| ...
require 'csv' require 'awesome_print' #_______________ Grocery::Customer _______________ module Grocery class Customer attr_reader :costumer_id, :email, :address # Initialize class Customer: def initialize(costumer_id, email, customer_address) @costumer_id = costumer_id @email = email ...
class FeedbacksController < ApplicationController before_action :correct_user, only: :destroy def new @feedback = Feedback.new end def create @feedback = Feedback.new(feedback_params) if @feedback.save flash[:success] = "Feedback Noted!" @partner = @feedback.partner red...
# encoding: utf-8 require "rubygems" require "rack" require_relative "ondl" require "uri" require "json" #require_relative "mecabread" class OndlKingApp def initialize(params={}) @ondl=Ondl.new(YahooAPI.new(params[:yahookey])) @baseurl="http://flexfrank.net/cgi/ondlking/index.html#" @bitlykey=params[:bitl...
# encoding: UTF-8 # Copyright 2012 Twitter, Inc # http://www.apache.org/licenses/LICENSE-2.0 require 'spec_helper' describe TwitterCldr::Formatters::NumberFormatter do let(:data_reader) { TwitterCldr::DataReaders::NumberDataReader.new(:sv, type: :decimal) } let(:formatter) { data_reader.formatter } let(:tokeni...
require 'rails_helper' RSpec.describe Order, type: :model do it "is valid" do expect(create(:order)).to be_valid end it "cancel order" do balance = 100 user = create(:user, balance: balance) event = create(:event, user_id: user.id) order = create(:order, state: "已预订", event_id: event.id, amo...
class SecretsController < ApplicationController def show redirect_to new_session_path if current_user.nil? end end
class Conversation < ApplicationRecord include PublicActivity::Common # https://www.nopio.com/blog/rails-real-time-chat-application-part-1/ has_many :matches has_many :users, through: :matches has_many :messages, dependent: :destroy # scope :with_long_title, -> { where("LENGTH(title) > 20...
class CreateStats < ActiveRecord::Migration def change drop_table :user_stats # These used to belong to user_stats. Moving them to the users table add_column :users, :wins, :integer, null: false, default: 0 add_column :users, :losses, :integer, null: false, default: 0 # This table will be shared...
require 'spec_helper' require 'date' describe 'Preconditions' do before(:all) do $caps_chrome['chromeOptions']['mobileEmulation'] = {'deviceName' => 'iPhone 5'} # Capybara.current_session.driver.browser.manage.window.resize_to(320,568) end after(:all) do Capybara.current_session.driver.quit # C...
# frozen_string_literal: true class Hireling < ApplicationRecord belongs_to :hire_class validates :name, :class, presence: true validates :name, uniqueness: true mount_uploader :image, ImageUploader end
class RatingPeriodProcessor def initialize(at) @at = at end def self.perform at = Time.zone.now.beginning_of_week processor = new(at) processor.process end def process Tournament.find_each do |tournament| tournament.with_lock do rating_period = tournament.rating_periods.cre...
require 'fog/openstack/core' require 'fog/openstack/common' require 'fog/openstack/volume' module Fog module Volume class OpenStack class V2 < Fog::Volume::OpenStack SUPPORTED_VERSIONS = /v2(\.(0-9))*/ requires :openstack_auth_url recognizes *@@recognizes model_path 'fog/...
class Product < ActiveRecord::Base has_many :orders has_many :comments, as: :commentable validates :name, presence: true validates :price, presence: true def price_in_cents if Rails.env.production? (price.to_f * 100).to_i else (price * 100).to_i end end def highest_rating_comment comments.rating...
describe 'Send an empty text' do before(:all) { @text = '' @returned_error_msg = 'No Input' } let(:get_text){ get "?text=#{@text}" } it 'Returned value should be a String' do get_text expect_json_types(error: :string) end it 'Introduced text should match on response' do get_text ...
require 'uri_validator' class TrainingLevel < ActiveRecord::Base include ActsAsTree has_many :subjects, :dependent => :destroy has_one :level_description has_many :competencies, :through => :level_description has_many :qualifications, :through => :level_description has_many :level_goals, :through => :lev...
# Hours in a year DAYS_IN_YEAR = 365.25 HOURS_IN_DAY = 24 def calc_hours_year hours_in_year = DAYS_IN_YEAR * HOURS_IN_DAY hours_in_year end year_result = calc_hours_year() puts("There are #{year_result.floor()} hours in a year.") # Minutes in a decade MINS_IN_HOUR = 60 def calc_mins_decade mins_in_day = HOUR...
# (c) Copyright 2016-2017 Hewlett Packard Enterprise Development LP # # 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 applicab...
class Object # Replace the +value+ of constant +name+ for the duration of a # +block+. This is especially useful when testing that the expected # class methods are being called on a Module or Class instance. # # Example: # # module Foo # BAR = :original # end # # Foo.stub_const(:BAR, ...
# frozen_string_literal: true # This service object is called when the Enrollment is complete module WasteExemptionsShared class FinalizeEnrollment attr_reader :enrollment, :exemption_duration class InvalidConfigurationError < StandardError; end def initialize(enrollment, exemptions_expire_after_durati...
class LabelsController < ApplicationController before_action :set_label, only:[:edit,:update,:destroy] def new @label = Label.new end def create @label = Label.new(label_params) if @label.save flash[:success] ='New Label created' redirect_to anaylsis_user_path(current_user.id) else...
require 'colorize' class Tile attr_accessor :value, :given def initialize(value, given) @value = value @given = given end def to_s given ? @value.to_s.colorize(:light_blue) : @value.to_s end end
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel...
class RailFenceCipher VERSION = 1 def self.encode(string, rails) new(string, rails).encode end def self.decode(string, rails) new(string, rails).decode end def encode char_collection = Array.new(rails, '') rail_char_cycle { |char, i| char_collection[i] += char } char_collection.join ...
module Coalla module PageSlider def slider(collection_name, options = {}) class_name = options.delete(:class_name) || 'SliderImage' slider_type = slider_type(collection_name) has_many collection_name, -> { where(slider_type: slider_type).order(:position) }, foreign_key: :container_slider_id, d...
class UserRepo < ROM::Repository[:users] commands :create, update: :by_pk def by_id(id) users.by_pk(id).one end def all users.to_a end end
class AddTexteToHomes < ActiveRecord::Migration[5.1] def change add_column :homes, :texte1_bloc1, :string add_column :homes, :texte2_bloc1, :string add_column :homes, :texte3_bloc1, :string end end
require 'sequel' require 'time' require 'date' require 'logger' require_relative 'egauge' def generation_since(start, register_name) query = <<-SQL select sum(watt_hours) as sum_wh from series s join registers r ON r.id = s.register_id where time >= ? and r.name = ? SQL result = DB[qu...
require "bundler/setup" require "salt" RSpec.configure do |config| # Enable flags like --only-failures and --next-failure config.example_status_persistence_file_path = ".rspec_status" # Disable RSpec exposing methods globally on `Module` and `main` config.disable_monkey_patching! config.expect_with :rspec ...
require_relative './Helpers/UserHelper' module MainApp module V1 class Users < Grape::API version 'v1', using: :path format :json prefix :api resources :users do desc 'Create new User' params do requires :role, :email requires :password, allow_blank: ...
class GamesController < ApplicationController before_action :authenticate_user!, except: [:show] def index @games = Game.includes(:type,:developer).paginate(:page => params[:page], :per_page => 6) end def new @game = Game.new @developers = Developer.all @types = Type.all end def show @game...
module Tictail class Api attr_accessor :agent, :store_id # @param [Fixnum] store_id def initialize(store_id = nil) @agent = Mechanize.new @store_id = store_id end # @param [String] method # @return [Hash] def get(method) url = 'https://tictail.com/apiv2/rpc/v1/?jsonrpc=...
require "test_helper" class TestMapnikMap < Test::Unit::TestCase def setup @map = Mapnik::Map.new end def test_should_initialize assert @map end def test_should_have_envelope assert @map.envelope.kind_of?(Mapnik::Envelope) end def test_should_have_styles assert @map.styles...
class AssignmentAnswer < ActiveRecord::Base belongs_to :assignment belongs_to :student validates_presence_of :title,:content has_attached_file :attachment , :url => "/assignment_answers/download_attachment?assignment_answer=:id", :path => "uploads/assignments/:assignment_id/:class/:id_partition/:basenam...
require "spec_helper" describe Bitemporal::Mongoid::Version do subject{ BitemporalSpec::Mongoid::Version.new } before{ Bitemporal.now = nil } should_have_field :master_id, :type => BSON::ObjectId should_have_field :created_at, :type => Time should_have_field :expired_at, :type => Time should_have_field :va...
module Player class Player attr_accessor :winner, :label, :turn def initialize(label) @winner = false @label = label @turn = false end end end
class CreateTopics < ActiveRecord::Migration def change create_table :topics do |t| t.string :title t.text :body t.boolean :published t.string :nickname t.integer :comment_count t.integer :visit_count t.timestamps end end end
# frozen_string_literal: true require 'indico' module ChartsHelper def self.posts_statistics(campaign) reactions = [] campaign.posts.each do |post| reactions << FacebookManager.get_post_reactions(post.fb_id, campaign.token) end process_reactions(reactions) end def self.post_statistics(pos...
# coding: utf-8 lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "value_semantics/version" Gem::Specification.new do |spec| spec.name = "value_semantics" spec.version = ValueSemantics::VERSION spec.authors = ["Tom Dalling"] spec.ema...
module EntryDataModel class Hiit < Base DEFAULT_DIMENSIONS = [ { name: :mult, options: {} }, { name: :time, options: {} }, { name: :load, options: {} }, { name: :pause, options: {} }, { name: :rest, options: {} } ].freeze end end
class Post < ApplicationRecord has_many :comments belongs_to :user scope :availables, -> { where(visible: true) } end
require 'faraday' require 'faraday_middleware' require_relative 'configurable' require_relative 'error/client_error' require_relative 'error/server_error' require_relative 'response/parse_json' require_relative 'response/raise_error' require_relative 'version' require 'logger' module Nipap module Default ENDPO...
class DashPage < SitePrism::Page section :nav, Sections::NavBar, '#navbar' element :view_title, '#page_title' end
json.array!(@tidbits) do |tidbit| json.action tidbit.action json.created_at tidbit.created_at case tidbit.action when 'Watch' profile = tidbit.targetable target = tidbit.profile when 'Favorite' profile = tidbit.targetable.profile target = tidbit.targetable.favable when 'Share' ...
# encoding: ascii-8bit require 'bundler' Bundler.setup require 'bitcoin' require_relative "blockchain/version" # The storage implementation supports different backends, which inherit from # Storage::StoreBase and implement the same interface. # Each backend returns Storage::Models objects to easily access helper metho...
class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception # Devise: before_action :authenticate_user! # Devise helpers: (-> for the RegistrationController) def after_si...
ActiveAdmin.register Task do filter :title filter :created_at index do id_column column :title column :body_task column :answer column :created_at column :updated_at default_actions end end
class TmversionsController < ApplicationController before_action :require_admin before_action :set_tmversion, only: [:edit, :update] def index @tmversions = Tmversion.all.order("version asc") end def new @tmversion = Tmversion.new end def edit end def update if @tmversion.update(tmversion_param...
require 'rails_helper' RSpec.describe Attachment, type: :model do it 'has a valid factory' do expect(create :attachment).to be_valid end end
require 'rails_helper' RSpec.describe "bookings/new", type: :view do before(:each) do assign(:booking, Booking.new(attributes_for(:booking))) end it "renders new booking form" do render assert_select "form[action=?][method=?]", bookings_path, "post" do assert_select "input[name=?]", "booking...
module Slickr module Generators class Renderer < Base def start template "renderer.erb", "lib/renderers/#{name}.rb" end end end end
Sequel.migration do change do create_table :users do primary_key :id String :email String :password_hash Time :creation Time :last_login end create_table :tokens do primary_key :id foreign_key :user, :users String :token TrueClass :valid Tim...
RSpec::Matchers.define :be_created_from do |expected| match do |actual| actual[:id].is_a?(Fixnum) && without_id(actual) == expected end def without_id(hash) hash.reject{|k,_| k == :id} end end
# This migration comes from mjbook (originally 20150105102624) class CreateMjbookSummaries < ActiveRecord::Migration def change create_table :summaries do |t| t.integer :company_id t.integer :companyaccount_id t.integer :payment_id t.integer :expend_id t.decimal :amount_in, :precisio...
class Seat < ApplicationRecord belongs_to :bus has_many :tickets, dependent: :destroy end
# frozen_string_literal: true require 'mysql2' require_relative '../../../lib/tidbits/mysql2/to_sql' describe NilClass do context '.to_sql' do it 'NULL' do expect(nil.to_sql).to eq('NULL') end end end describe String do context '.to_sql' do it 'escaped string' do expect("'\"\n\\".to_sq...
require 'open-uri' require 'nokogiri' namespace :db do desc "Fill database with data from zlacnene.sk" task fillup: :environment do #zlacnene.sk Price.destroy_all 'until<current_date' (1..56).each do |id| html = open("http://www.zlacnene.sk/tovar/hladaj/sk-potraviny/p/#{id}") doc = Nokogiri::HT...
class AddPrivateToAccounts < ActiveRecord::Migration def change add_column :usermanagement_accounts, :private, :boolean, null: false, default: false add_column :usermanagement_accounts, :created_by, :integer, index: true add_foreign_key :usermanagement_accounts, :usermanagement_people, column: :created_by...
require 'pry' class PigLatinizer def piglatinize(text) vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'] text.split(" ").map do |word| found = false word.split("") if vowels.include?(word[0]) # First character is a vowel word + "way" elsif !vowels.include?(word[0]) && !vowels.include?(word[1]) # ...
# Caller ID # --------- Then(/^the user can (?:also )?turn (.*?) the caller ID option$/) do |caller_id| initial_caller_id_value = on(SettingsPage).get_caller_id_setting caller_id.include?('ON') ? on(SettingsPage).display_caller_id(initial_caller_id_value) : on(SettingsPage).hide_caller_id(initial_caller_id_val...
require 'spec_helper' module Mirren module Rentals RSpec.describe Endpoints do let(:request) { double } let(:client) { MockClient.new(Endpoints).call(request) } let(:response) do "{ \"success\": #{response_success?}," \ " \"data\": #{response_data} }" end before do...
require 'spec_helper' describe Disqussion::Reactions do Disqussion::Configuration::VALID_FORMATS.each do |format| context ".new(:format => '#{format}')" do before do @client = Disqussion::Client.reactions end describe ".details" do before do stub_get("reactions/detail...
class AddIndexOnFinanceTransactionToFeeRefund < ActiveRecord::Migration def self.up add_index :fee_refunds, :finance_transaction_id, :name => "index_by_ft_id" end def self.down remove_index :fee_refunds, :name => "index_by_ft_id" end end
require_relative "../model" require "bigdecimal" class InvoiceItem < Model numeric_attrs "id", "item_id", "invoice_id", "quantity" data_attrs "created_at", "updated_at", "unit_price" def searchable_attributes ["id", "item_id", "invoice_id", "quantity"] end def unit_price BigDecimal.new(data["unit_p...
=begin toast = Proc.new { puts 'Cheers!' } 3.times { toast.call } do_you_like = Proc.new { |good_stuff| puts "I *really* like #{good_stuff}!" } do_you_like.call('chocolate') do_you_like.call('Ruby') =end =begin def do_self_importantly(some_proc) puts "Everybody just HOLD ON! I'm doing something..." some_proc.call...
# frozen_string_literal: true require 'rails_helper' describe 'フロント画面:ログインアカウントと同じ企業に紐づくUserの編集', type: :system do context 'ログインしているとき' do let!(:user) { FactoryBot.create(:user, company: login_user.company) } context '権限が not_grader のとき' do let(:login_user) { FactoryBot.create(:user, :not_grader) } ...
require_relative 'test_helper' require_relative '../lib/sales_engine' class MerchantTest < Minitest::Test attr_reader :merchant, :engine def setup @engine = SalesEngine.new row = {:id => "1", :name => "Schroeder-Jerde", :created_at => "2012-03-27 14:53:59 UTC", :updated_at => "2012-03-27 14:53:59 UTC"} @merc...
class EKGBuilder require 'set' def self.sequence(terms, seed = [1, 2], proc = nil) return seed if seed.length >= terms seq = seed used_terms = SortedSet.new(seed) proc ||= ->(a, b){ a.gcd(b) != 1 } (terms - seed.length).times do last_term = seq.last a_i = (1..Float::INFINITY).find ...
require 'spec_helper' RSpec.describe Ultron::Client do let(:serial) { double(RubySerial::Posix::Termios) } let(:mqtt) { MQTT::Client.new(host: 'localhost', port: 1883) } let(:config) do { serial: { port: '/dev/cu.usbmodem1421', rate: 9600 }, mqtt: { host: 'localhost...
FactoryGirl.define do factory :temp_birthday_party do cake nil quantity 1 birth_day "2016-08-30" delivery_time "2016-08-30 13:52:53" user nil sales_man nil message "MyText" delivery_address "MyString" birthday_person "MyString" person_avatar "MyString" end end
require 'spec_helper' describe Chanko do shared_examples_for 'exception' do let(:invoker) { Chanko::Test::Invoker.new } before do raise_chanko_exception end it 'should raise by :exception option' do error = StandardError.new('error') expect { Chanko::ExceptionNotifier.notif...
require 'sinatra' require 'sinatra/reloader' if development? require 'slim' require 'mongoid' Mongoid.load!('./mongoid.yml') # ############################## # Mongoid Document Section # ############################## class Restaurant include Mongoid::Document field :title, type: String field :id, type: Stri...
class AddTowerToSpreeAddresses < ActiveRecord::Migration def self.up add_column :spree_addresses, :tower_id, :integer end def self.down remove_column :spree_addresses, :tower_id end end
class Book attr_accessor :title def title bad_words = ["the", "a", "an", 'and', 'in', 'of'] answer = [] @title.split.each_with_index do |word, i| answer << ((i == 0 || !bad_words.include?(word)) ? word.capitalize : word) end @title = answer.join(' ') end end
require 'rails_helper' # rubocop:disable RSpec/AnyInstance # rubocop:disable RSpec/NestedGroups RSpec.describe FacilitiesManagement::ProcurementsController, type: :controller do let(:procurement) { create(:facilities_management_procurement, contract_name: 'New search', user: subject.current_user) } context 'witho...
class Rain < ActiveRecord::Base belongs_to :datarecord def self.get_bom_hash latest_time=Datarecord.last.update_time bom_hash=Hash.new for i in (0..Location.get_location_quantity-1) rain_fall=Datarecord.where(update_time: latest_time,record_source:'bom',record_type:'rain').find_by(location_id:i)....
class DisburseRule < ApplicationRecord validates :min_amount, presence: true, numericality: { greater_than: 0 } validates :percentage, presence: true, numericality: { greater_than: 0 } end
RSpec.describe "comparing two values" do it "compares two values using comparison operators" do expect(9).to be > 8 end it "compares two values using comparison operators" do expect(3).to be <= 6 end end