text
stringlengths
10
2.61M
# User model class class User < ApplicationRecord has_secure_password def subscriber? role == 'subscriber' end def admin? role == 'admin' end end
class ScoreCalc VALUE_LOSE = -5_000_000 LIMIT_EXP = 100 LIMIT_STATUS = 28 def self.load_pack(param_values_pack) @@values = param_values_pack end def self.summary_value(company) value = company_value(company) + heros_value(company) value end def self.company_value(company) value = 0 ...
include_recipe "chimpstation_base::workspace_directory" node.git_projects.each do |repo_name, repo_address| execute "clone #{repo_name}" do command "git clone #{repo_address} #{repo_name}" user WS_USER cwd "#{WS_HOME}/#{node['workspace_directory']}/" not_if { ::File.exists?("#{WS_HOME}/#{node['worksp...
# frozen_string_literal: true require "spec_helper" describe LiteCable::Config do let(:config) { LiteCable.config } it "sets defailts", :aggregate_failures do expect(config.coder).to eq LiteCable::Coders::JSON expect(config.identifier_coder).to eq LiteCable::Coders::Raw end end
require 'aws/broker/publishing' module Aws class Broker class Railtie < Rails::Railtie initializer 'aws-broker.extend_active_record' do ActiveSupport.on_load(:active_record) do ActiveRecord::Base.send(:extend, Aws::Broker::Publishing) end end end end end
# frozen_string_literal: true require 'sidekiq' module AppealsApi class NoticeOfDisagreementUploadStatusUpdater include Sidekiq::Worker sidekiq_options 'retry': true, unique_until: :success def perform(ids) NoticeOfDisagreement.where(id: ids).find_in_batches(batch_size: 100) do |batch| N...
class NetworkManager INPUT_NO = 2 #入力層のセル数 HIDDEN_NO = 2 #中間層のセル数 def initialize() @wh = [] #中間層の重み @vh =[] #中間層のしきい値 @wo = [] #出力槽の重み @vo =0.0 #出力層のしきい値 end attr_accessor :wh, :wo, :vh, :vo def init() init_wh() init_wo() init_vh() init_vo() end def init_wh() ...
require "spec_helper" RSpec.describe Game do it "should have a players hand" do Game.new.player_hand.cards.length.should eq(2) end it "should have a dealers hand" do Game.new.dealer_hand.cards.length.should eq(2) end it "should have a status" do Game.new.status.should_not be_nil end it "shou...
class AppointmentMailer < ApplicationMailer default from: 'hospital@kachirocks.com' before_action :retrieve_admins, only: %i[ new_appointment confirm_appointment change_of_doctor ] def new_appointment @appointment = params[:appointment] @patient = @appointment.patient.name @specialization = @ap...
# Single Element In a Sorted Array # # Given a sorted array consisting of only integers where every element # appears twice except for one element which appears once. Find this # single element that appears only once. Do it in O(log n) time and O(1) # space! # # things you should be thinking of: # - O(log n) should imm...
# Write a program that: # # Asks your user to enter any word and have it spelled out letter by letter. p "Enter a word for me to spell:" word = gets.chomp word = word.split("") word.each do |the_character| p the_character.upcase end
class User < ApplicationRecord has_many :bookings has_many :rooms, through: :bookings scope :booking_info, -> (id) { where(id: id).pluck("bookings.checkin_date","bookings.no_of_guests","rooms.room_type","rooms.no") } end
require 'rails_helper' RSpec.describe CustomersController, type: :controller do # Get customer list shared_examples_for "get customer list" do |record_count, params, expected_size| it "return customer list" do create_list(:customer, record_count) get :index, params: params expect(response.st...
require 'boolean_amenity_constraint' class BooleanAmenitiesController < ApplicationController include PropertiesHelper include SessionsHelper before_action :signed_in_user def new @amenity = BooleanAmenity.new end def create params = amenity_params @same_amenity = BooleanAmenity.find_by(params) ...
class Api::ThresholdsController < ApplicationController before_action :set_threshold, only: [:show, :update, :destroy] # GET /thresholds def index @thresholds = Threshold.all render json: @thresholds end # GET /thresholds/1 def show render json: @threshold end # POST /thresholds def cre...
# encoding: utf-8 # # © Copyright 2013 Hewlett-Packard Development Company, L.P. # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights #...
class BrandsController < ApplicationController skip_before_action :authenticate_user!, only: :scores def index if params[:query].present? @brands = Brand.search_by_name(params[:query]).order('name ASC') elsif params[:category] if params[:category] == 'All' @brands = Brand.all.order('nam...
DIRECTIONS = { 'E' => 0, 'S' => 1, 'W' => 2, 'N' => 3 }.freeze waypoint = Hash.new(0) waypoint['E'] = 10 waypoint['N'] = 1 route = Hash.new(0) def process(entry, route, directions, waypoint) case entry[:cmd] when 'F' move_forward(entry[:val], route, waypoint) when 'R' rotate_waypoint(entry[:val], waypoin...
# encoding: utf-8 $: << 'RspecTests' $: << 'RspecTests/Generated/array' require 'rspec' require 'generated/body_array' require 'helper' module ArrayModule include ArrayModule::Models describe ArrayModule::Array do before(:all) do @base_url = ENV['StubServerURI'] dummyToken =...
class ReservationsController < ApplicationController def index @reservations = Reservation.all end def show @reservation = Reservation.find(params[:id]) end def new @reservation = Reservation.new end def update @reservation = Reservation.find(params[:id]) if @reservation.update(cleaned_...
class Quote < ApplicationRecord belongs_to :mood has_many :user_moods end
class AddMetaToCategories < ActiveRecord::Migration[5.0] def change add_column :categories, :description, :text add_column :categories, :carriers, :text, array: true, default: [] end end
class HomeController < ApplicationController before_action :authenticate_user!, only: [:index] before_action :set_q, only: [:index, :search] before_action :set_scraping, only: [:index, :search] before_action :set_posts, only: [:index, :search] def index @graph = Post.group(:time).order(time: 'ASC')....
# encoding: utf-8 require "logstash/filters/base" require "logstash/namespace" # This filter lets you convert an event field ( that must be 12 strings character ) in to an Ean13 string with a checksum # This can be usefull if you need to output barcodes or some other sort of codes from a event field. # class LogStash:...
require 'test_helper' class SelfieChainTest < Minitest::Test def test_that_it_has_a_version_number refute_nil ::SelfieChain::VERSION end def setup @h = {a: {b: {}}} end def test_with_block assert_equal @h[:a][:b][:c].to_i.selfie(-1) {|x| x > 0}, -1 @h[:a][:b] = {c: "14"} assert_equal @h[:a][:...
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe Admin::CommentsController do fixtures :users before(:each) do login_as :quentin stub!(:reset_session) @blog = mock_model(Blog) @post = mock_model(Post) @user = mock_model(Use...
class Subject < ActiveRecord::Base # attr_accessible :title, :body has_many :pages validates_presence_of :name validates_length_of :name, :maximum => 255 end
class AddPathToWorkingArticle < ActiveRecord::Migration[5.2] def change add_column :working_articles, :publication_name, :string add_column :working_articles, :path, :string add_column :working_articles, :date, :date add_column :working_articles, :page_number, :integer add_column :working_articles...
require "rails_helper" RSpec.describe "Setting up a pool", js: true do let(:pool) { create(:pool) } let!(:contestants) { create_list(:contestant, 3, pool: pool) } let!(:other_contestant) { create(:contestant) } let!(:entries) { create_list(:entry, 3, pool: pool) } let!(:other_entry) { create(:entry) } bef...
class Shops::Admin::ExpressTemplatesController < Shops::Admin::BaseController before_action :set_express_template, only: [:show, :edit, :update, :destroy] # GET /express_templates # GET /express_templates.json def index @express_templates = current_shop.express_templates .page(params[:page]) .p...
require 'test_helper' class TaskTest < ActiveSupport::TestCase def setup @user = users(:first) @list = lists(:one) @task = @list.tasks.build(content: "Task content", user_id: @user.id) end test "should be valid" do assert @task.valid? end test "user id should be present" do @task...
class Reverse < Command def self.help return "Reverse the given message." end def self.run(nick, channel, msg) return msg.reverse end end
require 'spec_helper' describe Webex::Meeting::Action do custom_attributes = { meeting_key: 'fweofuw9873ri' } context '[PARAMS]delete' do api_type = 'DM' it '#api /m.php with custom set' do params = Webex::Meeting::Action.new(custom_attributes).delete expect(params['AT']).to eq api_typ...
require 'rubygems' require 'rake' begin require 'jeweler' Jeweler::Tasks.new do |gem| gem.name = "kindeditor" gem.summary = %Q{Rails KindEditor plugin} gem.description = %Q{Rails KindEditor integration plugin with paperclip support for rails3 Rc,it supports active_record and mongoid!} gem.email = "...
# frozen_string_literal: true module Types class LocationType < Types::BaseObject field :id, ID, null: false field :name, String, null: true field :description, String, null: true field :latitude, Float, null: true field :longitude, Float, null: true # Fetches the url of a stored image d...
# frozen_string_literal: true Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html # get 'tasks' => 'tasks#index', as: :tasks # get 'tasks/new' => 'tasks#new', as: :tasks_new # get 'tasks/:id' => 'tasks#show', as: :task # post 't...
class AddUrlToBands < ActiveRecord::Migration def change add_column :bands, :url, :string Band.initialize_urls end end
require "pp" module TicTacToe class Board PositionOccupiedError = Class.new(StandardError) OutOfBoundsError = Class.new(StandardError) def initialize @data = [[nil,nil,nil],[nil,nil,nil],[nil,nil,nil]] end def [](row,col) @data[row][col] end def []=(row,col,value) ...
# frozen_string_literal: true module Rabbitek class CLI ## # OS signal handlers class SignalHandlers SIGNALS = { INT: :shutdown, TERM: :shutdown }.freeze def self.setup(io_w) SIGNALS.each do |signal, hook| Signal.trap(signal) { io_w.write("#{hook}\n") ...
class Topic < ActiveRecord::Base attr_accessible :title, :questions_attributes has_many :questions accepts_nested_attributes_for :questions end
require 'spec_helper' describe RecyclingCenter do context 'before_validation' do it 'calls encode_location before validation' do rc = FactoryGirl.build(:recycling_center, lat: nil, lng: nil) rc.should_receive(:encode_location) rc.save end it 'reencodes lat and lng if address is change...
class ComplaintBuildingAsset < ActiveRecord::Base belongs_to :user validates_inclusion_of :repair_action, :in => [true, false] validates_inclusion_of :spare_part_action, :in => [true, false] validates :building_asset_type_id, :type_id, :item_id, :location, :serial_no, :reason, :presence => true has_many :...
class SearchController < ApplicationController before_filter :login_required before_filter :search_count def search_count @query = params[:query] @media_resources_count = MediaResource.search_count(@query, :conditions => {:creator_id => current_user.id, :is_removed => 0}) @media_share...
module Generamba VERSION = '1.5.0' RELEASE_DATE = '29.04.2019' RELEASE_LINK = "https://github.com/rambler-digital-solutions/Generamba/releases/tag/#{VERSION}" end
# frozen_string_literal: true require 'rails_helper' describe User, type: :model do let(:user) { create :user } describe 'validations' do subject { create :user } it { is_expected.to validate_presence_of(:uid) } it { is_expected.to validate_presence_of(:email) } it { is_expected.to validate_pres...
require 'singleton' module Ki class KiConfig include Singleton attr_reader :config, :environment def read(environment) @environment = environment @config = YAML.load_file(config_file_path)[environment] @config['cors'] ||= true end def config_file_path 'config.yml' e...
class Api::V1::TimelogsController < ApplicationController before_action :authenticate_user! before_action :set_timelog, only: [:show, :edit, :update] def index if params[:page] && params[:per] @timelogs = Logtime.page(params[:page]).per(params[:per]) else @timelogs = Logtime.limit(20) end render json: @time...
class AddIndexToMemberships < ActiveRecord::Migration def change add_index :memberships, [:user_id, :meetup_id, :owner], unique: true end end
begin require 'terminal-table' rescue LoadError puts "You must `gem install terminal-table` in order to use the rake tasks in #{__FILE__}" end namespace :rack_attack_admin do def clear puts "\e[H\e[2J" end desc "Watch the internal state of Rack::Attack. Similar to /admin/rack_attack but auto-refreshes, ...
FactoryBot.define do factory :hotel do name { Faker::Name.name } address { Faker::Address.full_address } phone { Faker::PhoneNumber.phone_number } latlng { "#{Faker::Address.latitude}, #{Faker::Address.longitude}" } price { Faker::Commerce.price } end end
# frozen_string_literal: true class InProgressFormCleaner include Sidekiq::Worker def perform Sentry::TagRainbows.tag forms = InProgressForm.where("updated_at < '#{InProgressForm::EXPIRES_AFTER.ago}'") logger.info("Deleting #{forms.count} old saved forms") forms.delete_all end end
module Bibliovore # Circulation information for copies of titles in individual library # locations class Copy # @return [Bibliovore::LibraryLocation] The location of the copies attr_reader :location attr_reader :status def initialize(data) @data = data @location = LibraryLocation.n...
class Challenge1 def self.balanced?(string) pairs = { ')' => '(', '}' => '{', ']' => '['} opening_char = ['(', '[', '{'] closing_char = [')', ']', '}'] stack = [] string.each_char do |item| #iterate to each character of array if opening_char.include?(item) #if it is an opening character...
class Admin::CategoriesController < Admin::ApplicationController before_filter :cat_id, :only => [:show, :edit, :update, :destroy] def index @categories = Category.all end def show @post = @category.posts end def new @category = Category.new(params[:category]) end def create ...
class CreateAttachments < ActiveRecord::Migration[5.0] def change create_table :attachments do |t| t.string :file_url t.references :quotation_comment t.timestamps end QuotationComment.where.not(s3_attachment_url: nil).find_each do |comment| Attachment.create!(quotation_comment: c...
class TransportTransactionDiscount < ActiveRecord::Base belongs_to :finance_transaction belongs_to :transport_fee_discount after_update :build_report_sync_job, :if => lambda { |x| x.is_active_changed? and !x.is_active } def deactivate finance_transaction.present? ? self.update_attribute('is_active', false...
module DowlOptParse class Formatter def initialize(schema) @schema = schema end def call formatted_options.join("\n") end def formatted_options @schema.map do |_, config| flags = [config[:long], config[:short]].compact flags_line = "#{flags.join(', ')} #{config[...
class ReportsMailer < ApplicationMailer def report_view(report) @report = report status = (report.state == "accepted") ? "Aceptado" : "Rechazado" mail(to: report.alumno.email, subject: "Reporte #{status}" ) end end
require 'robot' RSpec.describe Robot do let(:robot) { Robot.new.place(1, 1, 'wEst')} describe '#place' do context 'with valid attributes' do it 'places robot' do expect(robot.x).to be 1 expect(robot.y).to be 1 expect(robot.direction[:title]).to eq 'west' end end co...
require "spec_helper" RSpec.describe "Day 2: Inventory Management System" do let(:runner) { Runner.new("2018/02") } describe "Part One" do let(:solution) { runner.execute!(input, part: 1) } let(:input) do <<~TXT abcdef bababc abbcde abcccd aabcdd abcde...
class Event < ActiveRecord::Base validates_presence_of :name validates_numericality_of :budget, :greater_than => 0.0 has_many :expenses has_many :vendors, :through => :expenses def total_expenses expenses.sum(:amount) || BigDecimal("0.0") end def budget_exceeded? total_expenses > budget end ...
$pot = 0 def greeting puts "SLOTS".center(80) puts "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY".center(80) puts "\n\n" # PRODUCED BY FRED MIRABELLE AND BOB HARPER ON JAN 29, 1973 # IT SIMULATES THE SLOT MACHINE. puts "You are in the H&M Casino, in front of one of our" puts "one-arm bandit...
class GmailAPI class AuthError < RuntimeError; end def self.test acc = { login: "", passwd: "" } api = self.new(acc) api.login api.get_ads_for("the email id") end class CookieJar < Faraday::Middleware def initialize(app) super @cookies = {} end def pprint_meta(env, typ...
require_relative 'steaminventory/game.rb' require_relative 'steaminventory/tradingcard.rb' class Steaminventory VERSION = "1.0.0" def initialize(profile_id) @game = Game.new(profile_id) @card = TradingCard.new(profile_id) end def get_game_hash return @game.return_hash end def get_card_hash ...
require_relative '../../../../spec_helper' describe 'govuk_harden::sysctl::conf', :type => :define do let(:title) { 'zebra' } let(:pre_condition) { 'File <| tag == "govuk_harden::sysctl::conf" |>' } context 'source param' do let(:params) {{ :source => 'puppet:///llama' }} it { is_expected.to contain_fil...
# 问题: # 一只青蛙一次可以跳上1级台阶,也可以跳上2级台阶。求该青蛙跳上一个n级台阶总共有多少种跳法。 # # 一、构造状态转移方程: # # 题目中没有给粟子,我们可以自己举点例子。 # # 例如:跳上一个6级台阶,有多少种跳法;由于青蛙一次可以跳两阶,也可以跳一阶,所以我们可以分成两个情况: # 1、青蛙最后一次跳了两阶,问题变成了“跳上一个4级台阶台阶,有多少种跳法” # 2、青蛙最后一次跳了一阶,问题变成了“跳上一个5级台阶台阶,有多少种跳法” # 由上可得: # f(6) = f(5) + f(4); # f(5) = f(4) + f(3); # # 由此类推:f(n)=f(n-1)+f(n-2) #...
class CreateJobs < ActiveRecord::Migration def change create_table :jobs do |t| t.string :title t.integer :angellist_job_id t.string :job_type t.string :location t.string :role t.integer :salary_min t.integer :salary_max t.string :currency_code t.decimal :equi...
# The variable below will be randomly assigned as true or false. Write a method named time_of_day that, given a boolean as an argument, prints "It's daytime!" if the boolean is true and "It's nighttime!" if it's false. Pass daylight into the method as the argument to determine whether it's day or night. daylight = [tr...
# == Schema Information # # Table name: dictionaries # # id :integer not null, primary key # name :string(255) # tag :string(255) # ancestry :string(255) # created_at :datetime not null # updated_at :datetime not null # nam...
module Accounts class Withdraw def self.call(account, value) account.withdraw_balance(value) Transaction.new( sender_id: account.id, receiver_id: account.id, t_type: 'Withdrawal', value: value ) end end end
FactoryBot.define do factory :experience do place { Faker::Company.name } title { Faker::Job.title } description { Faker::Lorem.paragraph } start_date { Faker::Date.between 10.years.ago, Time.zone.today } end_date { Faker::Date.between start_date, Time.zone.today } applicant end end
require "spec_helper" describe ShowRundown do describe "associations" do it { should belong_to(:episode).class_name("ShowEpisode") } it { should belong_to(:segment).class_name("ShowSegment") } end describe "check_position" do it "only runs if position is blank" do rundown = create :show_rund...
module Issues class AssignIssueFollowers prepend SimpleCommand attr_reader :current_user, :args, :id, :followers def initialize(current_user, args) @id = args[:id] @users = args[:users] end def call return nil unless (valid_user? ...
class WelcomeController < ApplicationController NAMES = ["engineer world-class web-readiness", "unleash impactful platforms", "generate visionary synergies", "mesh cross-media interfaces", "morph value-added communities", "integrate scalable vortals", "optimize open-source systems", "incubate b...
lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'urbanairship/version' require 'rake' Gem::Specification.new do |spec| spec.name = "urbanairship_v3" spec.version = Urbanairship::VERSION spec.authors = ["Kenneth Lim"] spec.email ...
require 'nokogiri' require 'date' module RiksbankCurrency class Fetcher # @param [Date] date # @param [String] base currency def initialize(date, base) @date = date @base = base.to_s end # Convert XML response to Hash and recalculate it by @base currency # Example: # { ...
xml.instruct! xml.scenarios({:type => "array"}) do for scenario in @scenarios xml.scenario do xml.id({:type => "integer"}, scenario.id) xml.studentDebugAccess({:type => "boolean"}, scenario.student_debug_access) xml.name({:type => "string"}, scenario.name) xml.shortDescription({:type => ...
RSpec.describe Dabooks::Transaction do subject do Dabooks::Transaction.new( date: Date.new(2018, 1, 2), description: 'boo', entries: entries ) end let(:entries) do [ Dabooks::Entry.new( account: Dabooks::Account["cash"], amount: Dabooks::Amount[11], ), ...
require 'rails_helper' RSpec.describe User, type: :model do describe 'attributes' do it { expect(User.new).to respond_to(:name) } it { expect(User.new).to respond_to(:email) } it { expect(User.new).to respond_to(:country ) } end end
VAGRANTFILE_API_VERSION = "2" build_path = "#{File.dirname(__FILE__)}" project_root = build_path + '/../../../../' require 'yaml' require build_path + '/../src/vagrant.rb' Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| if File.exists?(project_root + 'devbox.yml') then DevBox.configure(config, YAM...
class Comment < ActiveRecord::Base belongs_to :reason validates :message, presence: true end
# Require monkey patches to standard libraries. Dir.glob("lib/extensions/**/*.rb") do |file| require_dependency File.expand_path(file) end
class GDG::Aracaju::Barcode < GDG::Barcode def name "Barcode Aracaju #{date}" end end
class AddCommuneToDiagnostiqueurs < ActiveRecord::Migration def change add_column :diagnostiqueurs, :commune, :string end end
class User < ActiveRecord::Base validates :username, presence: true, uniqueness: true validates :password, length: {minimum: 6} has_many :locations has_secure_password end
class CreateCourseChangeRecords < ActiveRecord::Migration def change create_table :course_change_records do |t| t.integer :course_id t.integer :teacher_user_id t.string :location t.string :time_expression t.string :semester_value t.datetime :start_date t.dat...
require 'graph' require 'path' describe Path do let(:graph) { Graph.new } let(:node_1) { 'A' } let(:node_2) { 'B' } let(:node_3) { 'C' } let(:edge_1_weight) { 1 } before do graph.add_node(node_1) graph.add_node(node_2) graph.add_edge(node_1, node_2, edge_1_weight) end describe '#distance' ...
module PUBG class Player class Season class Data class Attributes class GameModeStats require "pubg/player/season/data/stats" def initialize(args) @args = args end def solo Stats.new(@args["solo"]) en...
require 'test_helper' class WrappedErrorTest < Minitest::Spec let(:cause) { StandardError.new("the message") } let(:wrapped) do SimpleJsonapi::Errors::WrappedError.new( cause, id: "the id", status: "the status", code: "the code", title: "the title", detail: "the detail", ...
class ProLang < ApplicationRecord belongs_to :production belongs_to :language validates :production_id, presence:true validates :language_id, presence:true end
require 'spec_helper' describe "polymorphic associations" do # # has_moderated_association # has_many polymorphic # context "has_many polymorphic association:" do before do dynamic_models.task { has_many :renamed_subtasks, :class_name => "Subtask", :as => :parentable has_moderated_...
require 'rubygems' require 'bundler/setup' if ENV['COVERALL'] require 'coveralls' Coveralls.wear! end TEST_ENCODINGS = Encoding.name_list.each_with_object(['UTF-8']) do |encoding, result| test_string = '<script>'.encode(Encoding::UTF_8) string = begin test_string.encode(encoding) resc...
# Keep asking user for input and add their input to an array until they type "exit". # After that print out the number of input they've entered. For example print: # You've entered 10 inputs array = [] input = "" until input == "exit" print "Hit me (or 'exit' to give up): " input = gets.chomp.strip array << inpu...
# Copyright (c) 2009-2011 VMware, Inc. $:.unshift(File.dirname(__FILE__)) require 'spec_helper' require 'mysql_service/node' require 'mysql_service/mysql_error' require 'mysql2' require 'yajl' require 'fileutils' module VCAP module Services module Mysql class Node attr_reader :pool, :logger, :capa...
require File.dirname(__FILE__) + '/../spec_helper' describe ComentariosController do describe "route generation" do it "should map { :controller => 'comentarios', :action => 'index' } to /comentarios" do route_for(:controller => "comentarios", :action => "index").should == "/comentarios" end it...
describe package('ansible') do it { should be_installed } end
class ChangeGoalSoundNameFromStringToEnum < ActiveRecord::Migration def change remove_column :goals, :sound_name add_column :goals, :sound_name, :integer, default: 0 end end
class UploadedFilesController < ApplicationController def file_upload # FIX IE if request.headers["HTTP_ACCEPT"].split(",").map(&:strip).include?("application/json") content_type = "application/json" else content_type = "text/plain" end uploaded_file = UploadedFile.new(file: params[:f...
# frozen_string_literal: true require "hanami" module Hanamimastery # Handles HTTP requests. class App < Hanami::App config.actions.content_security_policy[:script_src] = "https://unpkg.com" config.shared_app_component_keys += ["mailers.contact_mailer"] end end
require File.expand_path("../test_helper", __FILE__) class HelloWorldTest < ProxyTest::TestCase def test_it_says_hello_world # Returns the real objects from the transaction res, req = expect :get, "/hello" do |response, request| # Modify the request inline request["X-Someotherheader"] = "thing" ...