text
stringlengths
10
2.61M
class ObservationRemarksController < ApplicationController before_filter :login_required filter_access_to :all def new @observation=Observation.find(params[:id]) @observation_remark = ObservationRemark.new end def create @observation_remark = ObservationRemark.new(params[:observation_remark]...
# frozen_string_literal: true require "socket" module Kafka # Opens sockets in a non-blocking fashion, ensuring that we're not stalling # for long periods of time. # # It's possible to set timeouts for connecting to the server, for reading data, # and for writing data. Whenever a timeout is exceeded, Errno...
class NPC < Character set_collection_name "npc" ensure_index "npc.characteristics" key :npc_id, ObjectId, :null => false, :required => true, :default => Mongo::ObjectID.new key :firstname, String, :null => false, :required => true key :lastname, String, :null =>...
json.array!(@prodtypes) do |prodtype| json.extract! prodtype, :id json.url prodtype_url(prodtype, format: :json) end
require 'spec_helper' describe Purchase, focus: true do describe "construction" do describe "from objects" do before(:each) do @purchase = Purchase.new({ count: 99, purchaser: FactoryGirl.create(:purchaser, name: "Hank Hill"), item: FactoryGirl.create(:ite...
RSpec.shared_context :logged_in do let(:user) { create(:user) } let(:organization) { create(:organization) } let(:owner) { organization.owner } before do @request.host = "#{organization.domain}.com" sign_in(user) end end
class CreateOfficeSpaces < ActiveRecord::Migration[5.1] def change create_table :office_spaces, id: :uuid do |t| t.boolean :emergency_exit, default: false, null: false t.integer :number_of_cumputers, default: 0, null: false t.integer :number_of_printers, default: 0, null: false t.integer :...
require 'sqlite3' module Twitter class SqliteIdentityMap include SQLite3 # It should be painfully obvious that this code is purely experimental and # should never be used in a production environment. GC.disable def initialize @database = Database.new(":memory:") end # @param id ...
require 'rack/file' module OMF::Web::Rack # Rack::MultiFile serves files which it looks for below an array # of +roots+ directories given, according to the # path info of the Rack request. # # Handlers can detect if bodies are a Rack::File, and use mechanisms # like sendfile on the +path+. # class Mul...
require 'spec/spec_helper' require 'maws/instance_matcher' describe 'InstanceMatcher' do before do @instance = mash(:role => 'app', :zone => 'a', :groups => %w(aws)) end it "matches single value filters" do InstanceMatcher.matches?(@instance, {:role => 'app'}).should be_true InstanceMatcher.matches?...
require 'test_helper' module FileUploadCache class TempfileTest < MiniTest::Unit::TestCase def test_for_binmode file_data = "OMGOMG" FileUploadCache::Tempfile.for(file_data, "omg.txt") do |temp_file| assert_equal file_data, temp_file.read assert_equal "omg.txt", temp_file.original_f...
require 'rails_helper' describe ClassroomsController do describe "POST #create" do before(:all) do @student = create(:active_student, register_number: 'CCC123') @course = create(:active_course) end context "when classroom is valid" do it "creates the classroom" do process :crea...
module Quantified class Length < Attribute system :metric do primitive :metre one :centimetre, :is => Length.new(0.01, :metres) one :millimetre, :is => Length.new(0.1, :centimetres) one :kilometre, :is => Length.new(1000, :metres) end system :imperial do primitive...
# typed: true class AddFieldsToUserTextCopies < ActiveRecord::Migration[6.0] def change add_column :user_text_copies, :pastes_used, :integer, default: 0 end end
class Api::V1::BaseApiController < ApplicationController respond_to :json before_filter :skip_trackable protected def skip_trackable request.env['devise.skip_trackable'] = true end def verified_request? super || User.where(authentication_token: params['auth_token']).count > 0 end en...
require 'spec_helper' include Susanoo::Filter describe "Susanoo::Filter" do describe "convert" do it "正しく変換できること" do converted = convert("あ", 'utf-8', 'euc-jp') expect(converted.ord).to eq("A4A2".hex ) end it "不正な文字を含む場合、不正な文字を除いた文字列が返ること" do converted = convert("①あ②", 'utf-8', 'euc-j...
class TrackingEventsController < ApplicationController before_action :authenticate_user! skip_after_action :intercom_rails_auto_include def create track_data = params.key?('data') ? data : {} analytics_track(label: label, data: track_data) end private def label params.require(:label) end ...
#!/usr/bin/env ruby #coding: UTF-8 system 'clear' require 'securerandom' def uri2file_path(arg) mode = arg.keys.first data = arg.values.first.strip data_type = data.class raise ArgumentError "некорректный тип данных '#{data_type}'" if not [String,Hash].include?(data_type) raise ArgumentError "некорректный ре...
require './lib/compact_disk' class Cd_keeper attr_reader :name, :description, :cds @@collections = [] def Cd_keeper.collections @@collections end def Cd_keeper.create(name, description) new_collection = Cd_keeper.new({:name => name, :description => description}) @@collections << new_collection...
#Fichero racional.rb require "./gcd.rb" class Racional attr_reader :dem,:num #inicinalizamos los objetos def initialize(num, denomin) #atributo @num=num @dem=denomin end #metodo para convertir en strings ...
# logic.rb # Chapter 7.4 (continuted) A little bit of Logic - starts on page 51 puts 'Hello, what\'s your name?' name = gets.chomp puts 'Hello, ' + name + '.' if name == 'Chris' puts 'What a lovely name!' else if name == 'Katy' puts 'What a lovely name!' end end puts 'Hello, what\'s your name?' name = gets...
#!/usr/bin/env ruby require_relative '../lib/chamois/target' require_relative '../lib/chamois/remote' require_relative '../lib/chamois/msg' require_relative 'spec_helper' describe Chamois::Target do let!(:remote_mock) { instance_double('Chamois::Remote') } subject(:c) { described_class.new(remote_mock) } let(:r...
class Pilot < ActiveRecord::Base has_many :missions has_many :spacecrafts, through: :missions end
class User < ActiveRecord::Base # Include default devise modules. Others available are: # :lockable, :confirmable, devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :timeoutable, :omniauthable, ...
include_recipe 'mackerel' include_recipe 'perl-json' package 'mackerel-check-plugins' cookbook_file '/etc/mackerel-agent/conf.d/check-plugins.conf' do owner 'root' group 'root' mode '0644' notifies :restart, 'service[mackerel-agent]' end cookbook_file '/etc/mackerel-agent/conf.d/check-plugins.conf' do owne...
class UsersController < ApplicationController before_action :require_signin, except: [:new, :create] # Checks to see if the user is signed in before_action :require_correct_user, only: [:edit, :update, :destroy] # Checks if the current user matches with the requested user info # The order in which you declare ...
class VariablesDrop < Liquid::Drop def initialize(variables) @variables = variables end def before_method(name) @variables[name] end def all @variables end end
Gem::Specification.new do |s| s.name = "talcotp" s.version = "0.3.1" s.license = "MIT" s.authors = ["Keeyan Nejad"] s.email = ["keeyan@keeyan.xyz"] s.homepage = "http://github.com/knejad/talcotp" s.summary = %q{TalcOTP is an otp password generator} s.files = `git...
#用户和标签的多对多的关系表 #用户可能有多个标签 ,一个标签可能有多个用户,这就是为何需要建立维护这个多对多的表格 # class CreatePUserTags < ActiveRecord::Migration def self.up create_table :p_user_tags do |t| t.string :pu_id #用户的百度user_id t.string :pc_id #用户在百度的channnel ID t.string :apikey #API key t.string :tag #用户的其中一个tag t.integer :ta...
module ROM class Repository include Concord::Public.new(:adapter) def [](name) adapter[name] end def connection adapter.connection end def respond_to_missing?(name, include_private = false) adapter[name] end def schema adapter.schema end private ...
# server details set :application, "webrepo" # this will be used to create the folder structure (see line) set :deploy_to, "/var/www/chemical/#{application}" default_run_options[:pty] = true ssh_options[:forward_agent] = true set :deploy_via, :remote_cache set :keep_releases, 10 set :user, "rethabile" set :use_sudo, ...
RSpec.configure do |config| config.before(:suite) do DatabaseCleaner.strategy = :transaction DatabaseCleaner.clean_with(:truncation) end # Order is important config.around clean_up: :truncate do |example| DatabaseCleaner.strategy = :truncation example.run # Execute cleaning DatabaseCleaner....
class Customer < ApplicationRecord # model associations belongs_to :company #validations validates_presence_of :name, :email end
module ApplicationHelper def pagination(options) render :partial => 'shared/pagination', :locals => options end def format_tweet(tweet) tweet = tweet.gsub /\s+/, ' ' tweet = auto_link_usernames(tweet) tweet = auto_link_tags(tweet) tweet = auto_link_urls(tweet) end def extract_mentioned_u...
class Person def initialize(pet, name = "Mason") @name = name @pet = pet end end
# This migration comes from inkwell (originally 20130202130030) class ChangeIsCommentToItemType < ActiveRecord::Migration def change add_column :inkwell_blog_items, :item_type, :string ::Inkwell::BlogItem.where(is_comment: true).update_all(item_type: 'c') ::Inkwell::BlogItem.where(is_comment: false).updat...
class StartGame attr_reader :board, :game WHITE_POSITIONS = [ 'Pawn a2', 'Pawn b2', 'Pawn c2', 'Pawn d2', 'Pawn e2', 'Pawn f2', 'Pawn g2', 'Pawn h2', 'Castle a1', 'Knight b1', 'Bishop c1', 'King d1', 'Queen e1', 'Bishop f1', 'Knight g1'...
class UserHoldersController < ApplicationController include UserHoldersHelper def index #DRY!!! TEMPORARY user_id = current_user.id selected_users = UserHolder.where(user_id: user_id).pluck(:objectguid) @holder = AdUser.joins("INNER JOIN user_holders ON ad_users.objectguid = user_holders.objectguid AND ...
#============================================================================== # # • Dhoom Text to Icon v.1.0a # drd-workshop.blogspot.com # -- Last Updated: 26.07.2015 # -- Requires: None # #============================================================================== # Convert any specified text into icon. You c...
class Prospect module Search extend ActiveSupport::Concern module ClassMethods # IMPORTANT: anytime we add new search filters, we need to update the assignment view to relay those parameters # look in admin/prospects/index for #assign def search(params) search_scope = Prospect.scop...
class CreateOnlineExamOptions < ActiveRecord::Migration def self.up create_table :online_exam_options do |t| t.references :online_exam_question t.text :option t.boolean :is_answer t.timestamps end end def self.down drop_table :online_exam_options end end
module Nutracoapi class Engine < ::Rails::Engine isolate_namespace Nutracoapi config.generators do |g| g.test_framework :rspec, :view_specs => false end config.to_prepare do root = Nutracoapi::Engine.root extenders_path = root + "app/extenders/**/*.rb" Dir.glob(extenders_path...
describe Ncr::WorkOrderReapprovalChecker do include ProposalSpecHelper describe '#requires_budget_reapproval?' do context "when the amount has been changed" do it "returns false by when the amount is decreased" do work_order = create(:ncr_work_order) work_order.setup_approvals_and_observe...
Rails.application.routes.draw do # get 'orders/index' # get 'orders/new' # get 'orders/create' devise_for :users root to: 'pages#home' get 'pages/ios' # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html resources :restaurants, only: [:index, :show, :new,...
class OpenFileError < StandardError def message "File does not exist" end end
class CreateAutoReplies < ActiveRecord::Migration def change create_table :auto_replies do |t| t.integer :company_id t.string :auto_text t.integer :status t.timestamps null: false end end end
require 'rails_helper' feature 'User can log out', %q{ In order to log out As an authenticated user I'd like to be able to end the session } do given(:user) {create(:user)} scenario 'Authenticated user tries to sing out' do sign_in(user) click_on 'Logout' expect(page).to have_content 'Sign...
# encoding: utf-8 module Sliders #possible movements of Rooks, Bishops and Queens def possible_moves(board) x, y = @position[0], @position[1] possible_moves = [] @directions.each do |i, j| px, py = x, y while true px += i py += j break if !is_on_board?(px, py) ...
require "minitest/autorun" require "nidyx" class TestCoreExt < Minitest::Test def test_camelize assert_equal("CamelCaseString", "camelCaseString".camelize) assert_equal("CamelCaseString", "camel_case_string".camelize) assert_equal("CamelCaseString", "Camel_Case_String".camelize) assert_equal("CamelCa...
require 'test/unit' require 'soap/rpc/standaloneServer' require 'soap/wsdlDriver' module WSDL module SimpleType class TestSimpleType < Test::Unit::TestCase class Server < ::SOAP::RPC::StandaloneServer def on_init add_document_method(self, 'urn:example.com:simpletype:ping', 'ping', XSD::QName.new...
require 'spec_helper' describe WebGame do let(:game) { TTT::Game.new(board: TTT::ThreeByThree.new, player1: TTT::Human.new, player2: TTT::AIEasy.new) } let(:web_game) { WebGame.new(game: game) } describe "current_player_ai?" do it "returns nil when a game's current_player is not an AI" do web_game.curr...
class ApplicationController < ActionController::Base protect_from_forgery before_filter :authenticate helper_method :is_using_real_mobile? helper_method :is_mobile_agent? helper_method :is_android_device? helper_method :current_user def current_user @current_user ||= User.find(session[:user_id]) if...
class Event < ActiveRecord::Base validates_presence_of :name, :campaign_id belongs_to :campaigns end
class SkillCategory < ActiveRecord::Base has_many :skills belongs_to :user acts_as_tenant(:user) default_scope { order(name: :asc) } scope :with_skills, -> { joins(:skills).where('skills.id IS NOT NULL').group('skill_categories.id') } validates :name, presence: true validates_uniqueness_to_tenant :nam...
class ExpensesController < ApplicationController def index @user = User.find(params[:user_id]) if params[:approved].nil? @expenses = Expense.where(user: @user, deleted: false) else @expenses = Expense.where(user: @user, approved: params[:approved], deleted: false) end if !params[:min...
class Player attr_accessor :bet_amount def initialize(name, bet_amount = 50) @name = name @icon = "NNN" @bet_amount = bet_amount end def name @name end def name=(string) @name end def icon @icon end def icon=(string) @icon = string en...
class Category < ApplicationRecord belongs_to :parent, class_name: :Category,optional: true has_many :children, class_name: :Category, foreign_key: :parent_id def self.getParentCategoriesArray parent_category = Category.where(parent_id: nil) parent_name = parent_category.pluck(:name) return parent_na...
=begin author : Elihu Alejandro Cruz Albores version 1.0.3 Nodo basico para almacenamiento de informacion =end class Node #Constructor por defeccto def initialize(data = nil, left = nil, right = nil) @data = data @level = 0 @left = left @right = right end d...
#!/usr/bin/env ruby require "colorize" require "date" require "fileutils" PATH = "#{ENV["HOME"]}/.never_do" EDITOR = ENV["EDITOR"] || "vi" class Task DELIM = "`" attr_reader :desc, :start, :finish def initialize(desc, start=-1, finish=-1) @desc = desc @start = start == -1 ? _now :...
class AddDetailsToTracks < ActiveRecord::Migration def self.up add_column :tracks, :height, :integer add_column :tracks, :platform_id, :integer add_column :tracks, :report_to, :integer add_column :tracks, :function_id, :integer add_column :tracks, :function_txt, :string end def self.down...
require "trick/function" module Trick module Value def self.extended(base) if base.superclass == Struct base.define_singleton_method(:[]) do |*args, &block| curry(base.members.count)[*args, &block] end end end def to_proc method(:new).to_proc end def ...
# -*- mode: ruby -*- # vi: set ft=ruby : # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # All Vagrant configuration is done here. The most common configuration # options are documented and c...
module Susanoo module Accessibility # #=== スタイル属性のチェック # font-size の pt、px、exを禁止する # class Style < Base def validate(doc) xpath = settings.target.xpath doc.xpath("#{xpath}//*[@style]").each_with_index do |e, i| styles = e['style'].split(';') styles.each do...
class CreateTaskObjectiveRevisionRecords < ActiveRecord::Migration def change create_table :task_objective_revisions do |t| t.references :task t.string :objective t.datetime :updated_on end add_index :task_objective_revisions, :task_id end end
require 'spec_helper' describe Susanoo::Exports::QrCodeCreator do describe "メソッド" do describe "#initialize" do let(:page) { create(:page_publish) } let(:item_resources) { [create(:page_publish)] } before do @rss_creator = Susanoo::Exports::RssCreator.new(page, item_resources) end...
#Attr Methods # I worked on this challenge [by myself, with:] # I spent [#] hours on this challenge. # Pseudocode =begin # Input: Name # Output: Greeting # Steps: Define two classes "NameData" and "Greetings" NameData will take a variable with my name (Use attr_methods for variables) Greetings will initialize an in...
class Forecasts::ProductsController < ApplicationController before_action :set_product, only: [:show, :edit, :update, :destroy] before_filter :new_product, only: [:new, :create] load_and_authorize_resource through: :current_forecast #skip_authorization_check # GET /products # GET /products.json def index ...
require "application_system_test_case" class MactansTest < ApplicationSystemTestCase setup do @mactan = mactans(:one) end test "visiting the index" do visit mactans_url assert_selector "h1", text: "Mactans" end test "creating a Mactan" do visit mactans_url click_on "New Mactan" fil...
require 'rails_helper' RSpec.describe "Core Settings - Unit of Measure", :type => :request do context "List all UoM" do before do user = create(:user) login_as(user, :scope => :user) end describe "GET Settings > Core > Unit of Measure" do it "should render UoM listing page" do ...
# -*- encoding : utf-8 -*- class AddWikipediaToArtists < ActiveRecord::Migration def change add_column :artists, :picture, :string #add_column :artists, :description, :text end end
# frozen_string_literal: true class AddDescriptionToBadges < ActiveRecord::Migration[6.0] def change add_column :badges, :description, :text end end
class BlogPostsController < ApplicationController layout 'blog_theme' before_action :check_admin, only: [:new, :create, :update, :edit] before_action :load_blog_post, only: [:edit, :update, :show, :destroy] def index @blog_posts = (@user.try(:admin?) ? BlogPost.all : BlogPost.published).order(created_at: :...
class AddNodeResourceToChatMessages < ActiveRecord::Migration def change remove_index :chat_messages, :from remove_column :chat_messages, :from change_table :chat_messages do |t| t.string :node t.string :domain t.string :resource end end end
class Trade < ActiveRecord::Base attr_accessible :user_id, :entry_date, :contract_period, :quantity, :buy_sell, :is_future, :is_call, :is_put, :premium, :strike, :price, :currency, :option_type before_save :set_defaults def set_defaults self.price = rand * 100 if self.price.nil? or self.price.zero? sel...
module V1 class Parkings::PayController < ApplicationController before_action :load_parking, only: [:update] def update if @parking.update_attributes(paid: true) return head :ok end head 422 end private def load_parking @parking = Parking.find(params[:id]) en...
module Serious class Description def initialize(title, &block) @_title = title @_block = block end def evaluate instance_eval(&@_block) end private def it(title, &block) behavior = Serious::Behavior.new(title, &block) behavior.evaluate end end end
#!/usr/bin/ruby require 'xmmsclient' require './exceptions' # Handles the rules for virtual paths. class VirtualPaths def initialize(xc) @rules = Hash.new @xc = xc end def add_rule(name, path_spec) raise DuplicateRuleException.new(name) if @rules.key?(name) if path_spec.match(/^\//) @...
# frozen_string_literal: true require "uber/arguments" require "uber/api_request" require "uber/models/time" module Uber module API module TimeEstimates def time_estimations(*args) arguments = Uber::Arguments.new(args) perform_with_objects( :get, "/v1/estimates/time", ...
require 'helper' require 'scaler_tests' module Axon class TestNearestNeighborScaler < AxonTestCase include ScalerTests def setup super @scalerclass = NearestNeighborScaler @scalertestclass = TestNearestNeighborScaler end class TestNearestNeighborScaler def initialize(origina...
class BikeracksController < ApplicationController def lat_lng @lat_lng ||= session[:lat_lng] ||= get_geolocation_data_the_hard_way end def index if !params[:search].present? @bracks = BikeRack.all @search_result = BikeRack.all else @result = params[:search].split(' ').map{|i| "%#{i}%"}.join(' ') ...
#!/usr/bin/env ruby # frozen_string_literal: false # # check-chrony.rb # # Author: Matteo Cerutti <matteo.cerutti@hotmail.co.uk> # require 'sensu-plugin/check/cli' require 'socket' require 'json' class CheckChrony < Sensu::Plugin::Check::CLI option :chronyc_cmd, description: 'Path to chronyc executable (d...
# 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...
require 'spec_helper' describe Webex::Meeting::Attendee do custom_attributes = { meeting_key: 'fweofuw9873ri' } attendee_attributes = [{ FullName: 'FullName1', EmailAddress: 'nil', PhoneCountry: 'nil', PhoneArea: 'nil', PhoneLocal: 'nil', PhoneExt: 'nil', TimeZone: 'nil', Language: 'nil', Locale: 'nil', AddToAddre...
class UI SCORE_X = 10 SCORE_Y = 10 SCORE_COLOR = 0xff_ffff00 LIVES_X = 10 LIVES_X_SHIFT = 39 LIVES_Y = 60 MOVE_FROM_THE_CENTER_Y = 50 PRESS_SPACE_LOW = 210 PRESS_SPACE_HIGH = 270 def initialize ...
# # Author:: Alessio Rocchi (<alessio.rocchi@staff.aruba.it>) # © Copyright ArubaCloud. # # LICENSE: MIT (http://opensource.org/licenses/MIT) # require 'rubygems' require 'fog/arubacloud' require 'optparse' options = {} OptionParser.new do |opts| opts.banner = 'Usage: get_servers.rb [options]' opts.on('-uUSERNAME...
languages = { :oo => { :ruby => { :type => "interpreted" }, :javascript => { :type => "interpreted" }, :python => { :type => "interpreted" }, :java => { :type => "compiled" } }, :functional => { :clojure => { :type => "compiled" }, :erlan...
FactoryBot.define do sequence :user_authentication_token do |n| "xxxx#{Time.zone.now.to_i}#{rand(1000)}#{n}xxxxxxxxxxxxx" end sequence(:random_email) { Faker::Internet.email } factory :user, class: User do email { generate(:random_email) } password "Secret08" password_confirmation { password ...
# U3.W8: REVISIT BONUS SQLite Gem # I worked on this challenge [by myself and then some with Patrick] require 'sqlite3' $db = SQLite3::Database.open "congress_poll_results.db" # Uses congress_poll_results.db as the database, opens it and using SQLite3 establishes this information as a Global Variable. def print_ar...
class TestSquad::InstallGenerator < Rails::Generators::Base source_root File.expand_path('../templates', __FILE__) SKIP_RAILS_ASSETS = %w[jasmine] class_option :framework, type: 'string', desc: 'Select the JavaScript framework. Can be jasmine, qunit, mocha or ember.', aliases: '-f', required: tr...
class Timer attr_accessor :seconds def initialize @seconds=0 end def time_string hours=@seconds/3600 remainder=@seconds%3600 minutes=remainder/60 seconds=remainder%60 "#{padded(hours)}:#{padded(minutes)}:#{padded(seconds)}" end def padded time if time<10 "0#{time.to_s}" else time.to_s ...
class AddSelfJoinToDirectories < ActiveRecord::Migration[5.2] def change add_reference :directories, :ref_directory, foreign_key: { to_table: :directories } end end
require 'test_helper' class UsersSignUpTest < ActionDispatch::IntegrationTest test "sign up layout" do visit new_user_registration_path assert page.has_css?("form#new_user") assert page.has_field?("Email", type: "email") assert page.has_field?("Name", type: "text") assert page.has_field?("Pass...
class FixSubscribersGroupMembersConstraints < ActiveRecord::Migration def change rename_column :subscribers_group_members, :user_subscribers_group_id, :subscribers_group_id add_foreign_key :subscribers_group_members, :subscribers_groups, on_delete: :cascade add_foreign_key :subscribers_group_members, :use...
class PowersController < ApplicationController before_action :confirm_logged_in before_action :find_power, only: [:show, :edit, :update, :destroy] def index @powers = Power.all end def new @power = Power.new end def create @power = Power.create(power_params) if @power.save redirect_to...
require 'rails_helper' describe Task do it "is valid with a title, start_date and end_date" do task = Task.new( title: 'Correr en la mañana', start_date: Time.now, end_date: Time.now+2.hours) expect(task).to be_valid end it "is invalid without a title" do task = Task.new(title: nil...
# 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 rails db:seed command (or created alongside the database with db:setup). # # Examples: # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Ch...
# frozen_string_literal: true module Decidim module Opinions module Admin # A command with all the business logic when an admin creates a private note opinion. class CreateOpinionNote < Rectify::Command # Public: Initializes the command. # # form - A form object with t...
# # Generator for new rails apps. # # Created by payton. # module Thor::Actions def source_paths [File.dirname(__FILE__)] end end create_file ".ruby-version", "1.9.3@#{app_name}" gem 'rails', '3.2.11' gem 'sqlite3', group: [:development, :test] gem 'pg', group: :production gem 'sass-rails', '~> 3.2.3' gem ...
require 'absolute_renamer/interpreters/base' module AbsoluteRenamer module Interpreters class CounterInterpreter < Base def initialize @counters = {} end def search_and_replace(part_name, new_value, path_handler) new_value.gsub(pattern).with_index do |_, counter| coun...
module UserOperationsMixin extend ActiveSupport::Concern def add_request req = RequestCreateService.new(params.require(:workflow_id)).create(request_params) json_response(req, :created) end def fetch_request_by_id req = Request.find(params.require(:id)) json_response(req) end def fetch_re...