text stringlengths 10 2.61M |
|---|
class Todo < ActiveRecord::Base
acts_as_list
belongs_to :user
validates :minutes, :task, presence: true
def self.assign_times(startpos)
todo=Todo.where("position > #{startpos}").order("starttime asc").first
if todo.starttime != nil
starting_time = todo.starttime
else
starting_time = Time.zone.now.beg... |
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# username :string not null
# password_digest :string not null
# session_token :string not null
# created_at :datetime not null
# updated_at :datetime ... |
# Write methods to implement the multiply, subtract, and divide operations for
# integers. The results of all these are integers. Use only the add operator
def multiply(num1, num2)
result = 0
if num1 > num2
num2.times do
result += num1
end
else
num1.times do
result += num2
end
end
... |
require 'test/unit'
require 'record_roo'
class Product
attr_accessor :key, :name, :price, :category
def initialize fake
end
end
class RecordTest < Test::Unit::TestCase
include RecordRoo
def setup
config_path = File.expand_path("../data", __FILE__)
@filepath = "#{config_path}/products"
... |
require 'rails_helper'
require './spec/helpers/account'
describe 'User Accounts' do
context 'account creation' do
it 'can create an account' do
visit '/users/sign_up'
fill_in 'user_email', with: 'foo@bar.co.uk'
fill_in 'user_password', with: '123456'
fill_in 'user_password_confirmation', ... |
describe Darklite::Utils do
let(:first_second) do
Time.local(2015, 9, 1, 0, 0, 1)
end
let(:last_second) do
Time.local(2015, 9, 1, 23, 59, 59)
end
let(:sunrise) do
Time.local(2015, 9, 1, 6, 40, 0)
end
let(:sunset) do
Time.local(2015, 9, 1, 19, 39, 0)
end
describe '#convert_to_second... |
class Tree
attr_accessor :children, :value
def initialize(v,parent=nil)
@value = v
@children = []
@parent = lambda { parent }
end
def addChild(v)
newTree = Tree.new(v,self)
end
def parent
@parent.call()
end
def parent=(other)
@parent = lambda {other}
end
end
def List
attr_... |
require_relative "my_stack.rb"
class MyStackQueue
def initialize
@push_stack = MyStack.new
@pop_stack = MyStack.new
end
#stack1 [3,2,1] <- top of the stack front of the queue
#stack2 [4,5] <- top of the stack end of the queue
#enequeue
#stack1 [3,2,1,0]
#stack2 [4,... |
module Refinery
module Albums
class Album < Refinery::Core::BaseModel
self.table_name = 'refinery_albums'
attr_accessible :title, :date, :photo_id, :summary, :description, :purchase_link, :position
acts_as_indexed :fields => [:title, :summary, :description, :purchase_link]
validates :ti... |
class Article < ApplicationRecord
has_many :comments, dependent: :destroy
has_many :users, through: :comments
#allows us to delete associated comments along with deleted articles
validates :title, presence: true, length: { minimum: 5 }
validates :text, presence: true, length: {minimum: 2}
#arti... |
class StickersController < ApplicationController
def index
@stickers = Sticker.order(:order)
end
end
|
require 'rails_helper.rb'
require_relative '../../db/migrate/20180628172800_add_dimensions_to_attachments.rb'
describe AddDimensionsToAttachments do
let(:rr) { create :reporting_relationship, active: false }
after do
ActiveRecord::Migrator.migrate Rails.root.join('db', 'migrate'), @current_migration
Messa... |
class BakerAndTaylor < BookStore
def initialize(value)
@base_url = "http://www.baker-taylor.com/gs-searchresults.cfm"
@options = {"search" => value}
@results = ".gsc-table-result .gsc-webResult"
@item = "table .gs-title a"
end
end |
class Game < ApplicationRecord
belongs_to :user
def final_score
(self.end_time - self.start_time)
end
end
|
# -*- coding: utf-8 -*-
class UserAvatarAdpater
def initialize(user, raw_file)
@raw_file = raw_file
user_id_str = user.id.to_s
@temp_file_entity = FileEntity.create :attach => raw_file
# @temp_file_dir = File.join(TEMP_FILE_BASE_DIR, user_id_str)
# @temp_file_name = File.join(@temp_file_dir,... |
class CreateResults < ActiveRecord::Migration
def self.up
create_table :results do |t|
t.integer :score
t.integer :correct
t.integer :wrong
t.references :question, index: true, foreign_key: true
t.timestamps null: false
end
end
def self.down
drop_table :results
end
e... |
Rails.application.routes.draw do
resources :tweets
root 'static_pages#home'
match 'help', to: 'static_pages#help', via: 'get'
resources :users
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 bin/rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# ... |
module SequelSpec
module Matchers
module Validation
class ValidateNotNullMatcher < ValidateMatcher
def description
desc = "validate that #{@attribute.inspect} is not null"
desc << " with option(s) #{hash_to_nice_string @options}" unless @options.empty?
desc
end
... |
require "test_helper"
describe Review do
let(:review) { Review.new }
let(:review1) {reviews(:review1)}
it "rating must be present" do
review1.valid?.must_equal true
review1.rating = nil
review1.valid?.must_equal false
review1.save
review1.errors.keys.must_include :rating
end
it "rating ... |
require 'rails_helper'
describe Room do
it { should belong_to(:home) }
it { should have_many(:temperatures) }
it { should validate_presence_of :name }
it { should validate_presence_of :temp_setting }
end
|
puts "Please write word or multiple words:"
words = gets.chomp
puts "There are #{words.delete(" ").length} characters in '#{words}'"
|
class Device < ActiveRecord::Base
belongs_to :member
belongs_to :division
has_many :proofs
def last_proof
self.proofs.last
end
def ave_de(date_filter)
Device.device_average_de(self, date_filter)
end
def quantities(date_filter)
Device.device_sticker_quantities(date_filter, self)
en... |
# Problem 321: Swapping Counters
# http://projecteuler.net/problem=321
# A horizontal row comprising of 2n + 1 squares has n red counters placed at one end and n blue counters at the other end, being separated by a single empty square in the centre. For example, when n = 3.
#
# http://projecteuler.net/project/images... |
class MessageConsumer
include Hutch::Consumer
KEY = 'test.message'
consume KEY
queue_name 'message_consumer'
def process(message)
puts message.payload
end
end
|
class Searchers::UserSearcher
def search(users_relation, query)
users = perform_search(users_relation, query, false)
# If the result set does not contain any results, we need to loosen up our requirements
if users.count == 0
users = perform_search(users_relation, query, true)
end
users
... |
class User < ActiveRecord::Base
has_secure_password
has_many :products, foreign_key: "user_id", dependent: :destroy
validates :email, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, on: :create }
validates :email, uniqueness: { case_sensitive: false }
validates :username, length: { in: 2..15 ... |
class Ultrasonic < AbstractReport
has_one :report, as: :specific, dependent: :destroy
has_many :ut_defects, dependent: :destroy
has_many :ut_probes, dependent: :destroy
attr_accessible :equipment,
:sensitivity,
:couplant,
:correction,
:report_attributes,
:ut_defects_attributes,
:calibration_date,
... |
require 'spec_helper'
# Helper method that converts string to the dumped representation
# @param value [String] original string
# @return [String] dump representation
def string_to_dump(value)
parsed_value = Liquid::Template.parse(value)
Base64.strict_encode64(Marshal.dump(parsed_value))
end
RSpec.describe Liquid... |
class Movie < ApplicationRecord
AMOUNT_OF_MOVIES = 4
validates :name, presence: true
belongs_to :category
scope :different_movies, -> (movie) {
where("id <> ?", movie.id).limit(AMOUNT_OF_MOVIES)
}
scope :sorted, -> { order(name: :asc) }
end
|
class Publish::PaymentsController < PublishController
belongs_to :publisher
private
def collection
@payments = Payment.find(:all, :conditions => { :owner_id => current_publisher.id, :owner_type => 'Publisher' }).map do |a|
a if a.is_test_deposit? == false
end.compact
end
end
|
feature "Messages stream" do
scenario "Messages stream is public and can be seen by guests" do
sign_up
sign_in
fill_in :body, with: "This is a test"
click_button "Send"
click_button "Sign Out"
click_link "Conversation"
expect(page).to have_content "This is a test"
end
end |
class RefactorStatusOfFunnelsAndCandidates < ActiveRecord::Migration
def self.up
add_column :candidates, :in_funnel, :boolean, :default => false
add_column :funnels, :result, :text, :size => 32
add_column :funnels, :is_active, :boolean, :default => true
add_index :funnels, :is_active
ad... |
class AuthenticationController < ApplicationController
def create
found_user = User.find_by_linkedin_id(params['linkedin_id'])
if found_user == nil
@user = User.new(:linkedin_id => params['linkedin_id'],
:email => params['linkedin_id'] + "@email.com",
... |
class CreateMaterialAssignments < ActiveRecord::Migration
def up
create_table :material_assignments do |t|
t.integer :task_id, :null => false
t.integer :material_id, :null => false
t.integer :assignment_id, :null => false
t.integer :qty_sent, :null => false
t.integer :qt... |
describe DockingStation do
let(:bike) { double(Bike.new) }
context 'Upon creation' do
it 'is empty' do
expect(subject.bikes).to eq []
end
it 'has capacity of 4' do
expect(subject.capacity).to eq 4
end
end
context 'can receive' do
it 'a working bike' do
subject.add_bike(b... |
require 'pry'
BEST_SCORE = 21
TOTAL_WINS = 5
@ranks = %w[2 3 4 5 6 7 8 9 10 Jack Queen King Ace]
@suits = %w[Hearts Spades Diamonds Clubs]
@cards = []
@ranks.each do |rank|
@suits.each do |suit|
@cards << [rank, suit]
end
end
def prompt(msg)
puts "=> #{msg}"
end
def total_value(cards)
values = cards.ma... |
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
require 'fileutils'
require 'open-uri'
module TwitterCldr
module Resources
class SegmentDictionariesImporter < Importer
URL_TEMPLATE = 'https://raw.githubusercontent.com/unicode-org/icu/%{tag}/%{path}'
DIC... |
Rails.application.routes.draw do
resources :articles
devise_for :users
mount TranslationCenter::Engine => "/translation_center"
root to: "articles#index"
end
|
require_relative "../test_helper"
require_relative "../../lib/recommended_links/indexer"
require 'rummageable'
module RecommendedLinks
class IndexerTest < Test::Unit::TestCase
test "Indexing a recommended link adds it to the search index" do
recommended_link = RecommendedLink.new(
"Care homes",
... |
class FontNotoSansTelugu < Formula
head "https://noto-website-2.storage.googleapis.com/pkgs/NotoSansTelugu-unhinted.zip", verified: "noto-website-2.storage.googleapis.com/"
desc "Noto Sans Telugu"
homepage "https://www.google.com/get/noto/#sans-telu"
def install
(share/"fonts").install "NotoSansTelugu-Regul... |
FactoryGirl.define do
factory :user do
first_name 'Earving'
last_name 'Winkleson'
sequence(:email) { |n| "earving#{n}@winkleson.com" }
password 'MyTest1234'
end
end
|
class AddStationToBillInfos < ActiveRecord::Migration[5.0]
def change
add_reference :bill_infos, :station, foreign_key: true
end
end
|
require "spec_helper"
describe "AttrArgsShorthand" do
let!(:test_object_level_1) { TestObjectLevel.new(arg1: 'test1', arg2: 'test2') }
let!(:test_object_level_2) { TestObjectLevel.new(arg3: 'test3', arg4: 'test4') }
let!(:test_class_level_1) { TestClassLevel.new(arg1: 'test1', arg2: 'test2') }
let!(:test_clas... |
class ParamParser
attr_reader :parsed_url
def initialize(url_param)
@parsed_url = url_param.split(' ')
end
def path
parsed_url[0]
end
def email
parsed_url[2]
end
def mailable?
parsed_url[1] == '\cc:'
end
end
|
# config valid only for current version of Capistrano
lock "3.14.1"
set :application, "personal-website"
set :scm, :middleman
namespace :deploy do
task :create_symlinks do
on roles(:all) do
info "Deleting old symbolic links"
execute "find /home/public -type l -delete"
info "Creating symbolic ... |
module PUBG
class Telemetry
class Location
attr_reader :x, :y, :z
def initialize(args)
@x = args["X"]
@y = args["Y"]
@z = args["Z"]
end
end
end
end |
# == Schema Information
#
# Table name: rounds
#
# id :integer not null, primary key
# tournament_id :integer not null
# active :boolean default(TRUE)
# created_at :datetime not null
# updated_at :datetime not null
# round_number :integer ... |
class AddFraseCuandoSiguenToBots < ActiveRecord::Migration
def change
add_column :bots, :frase_cuando_siguen, :string
end
end
|
# text interface for transport manipulation
module Terminal
class TextCommandor
attr_reader :commands, :stations, :routes, :trains, :carriages
def initialize(storage)
@commands = []
@storage = storage
end
def add_menu_item(name, type, options = {})
@commands << command_dispatcher(t... |
require 'redmine'
Redmine::Plugin.register :selectbox_autocompleter do
name 'Selectbox Autocompleter plugin'
author 'heriet'
description 'This plugin generate Autocomplete box for Select box'
version '1.2.1'
url 'https://github.com/heriet/redmine-selectbox-autocompleter'
author_url 'http://heriet.info'
... |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def show_qtiest?( params )
condition_1_qtiest?(params) or
condition_2_qtiest?(params) or
condition_3_qtiest?(params)
end
def show_mycute?( params )
params[:controller] == "upload... |
class Like < ActiveRecord::Base
belongs_to :user
belongs_to :pin
validates :user_id, presence: true
validates :pin_id, presence: true
validates_uniqueness_of :user_id, :scope => :pin_id
end
|
class AddSelfAssignableToShifts < ActiveRecord::Migration
def change
add_column :shifts, :self_assignable, :boolean
add_column :shifts, :requestable , :boolean
end
end
|
# prereqs: iterators, hashes, conditional logic
# Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash)
min_value = 10000
#set default super high so all values would be less
# would be better to set default to first value but could not find a way to do this wit... |
class CollegeActivity < ApplicationRecord
belongs_to :college
belongs_to :activity
end
|
# frozen_string_literal: true
# Loads data from KKTIX group to database
class SaveOrganization
extend Dry::Monads::Either::Mixin
extend Dry::Container::Mixin
register :check_if_org_exist, lambda { |org_json|
puts org_json
if (org = Organization.find(slug: org_json['slug'])).nil?
Right(org: Organiz... |
# frozen_string_literal: true
require 'rails_helper'
describe Documents::AttachmentsController do
let(:owner) { create(:user, :with_sessions, :with_documents) }
let(:guest) { create(:user, :with_sessions) }
let(:stranger) { create(:user, :with_sessions) }
let(:owner_token) { owner.sessions.active.first.token ... |
#!/usr/bin/env ruby
case ARGV[0]
when "start"
STDOUT.puts "called start"
when "stop"
STDOUT.puts "called stop"
when "restart"
STDOUT.puts "called restart"
else
STDOUT.puts "Unknown"
end
|
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def application_name
'KBs ADL Hydra Head'
end
end
|
module DaisyUtils
EXPECTED_DTD_FILES = ['dtbook-2005-2.dtd', 'dtbook-2005-3.dtd']
def valid_daisy_zip?(file)
DaisyUtils.valid_daisy_zip?(file)
end
def self.valid_daisy_zip?(file)
Zip::Archive.open(file) do |zipfile|
zipfile.each do |entry|
if EXPECTED_DTD_FILES.include? entry.na... |
# == Schema Information
#
# Table name: media
#
# id :string primary key
# app :string(100)
# context :string(100)
# locale :string(10)
# tags :string
# content_type :string(100)
# url :string
# name :string(100)
# lock_version :integer ... |
module Ipizza
module Provider
class << self
def get(provider_name)
case provider_name.to_s.downcase
when 'lhv'
Ipizza::Provider::Lhv.new
when 'swedbank', 'hp'
Ipizza::Provider::Swedbank.new
when 'eyp', 'seb'
Ipizza::Provider::Seb.new
whe... |
require "test_helper"
describe SessionsController do
it "logs in an existing merchant and redirect to root_path" do
@merchant = merchants(:sappy1)
start_count = Merchant.count
login(@merchant, :github)
Merchant.count.must_equal start_count
must_redirect_to merchant_path(@merchant.id)
session... |
class AddDebitAccountAndCreditAccountToTransactions < ActiveRecord::Migration
def change
add_reference :transactions, :debit, polymorphic: true, index: true
add_reference :transactions, :credit, polymorphic: true, index: true
end
end
|
Fabricator(:author) do
feed { |author| Fabricate(:feed, :author => author) }
username "user"
email { sequence(:email) { |i| "user_#{i}@example.com" } }
website "http://example.com"
domain "http://foo.example.com"
name "Something"
bio "Hi, I do stuff."
end
|
# encoding: UTF-8
# Copyright 2017 Max Trense
#
# 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 agre... |
module UsersHelper
def log_in(user)
session[:user_id] = user.id
cookies.signed[:user_id] = user.id
end
def logged_in_user
unless logged_in?
redirect_to root_path
end
end
def correct_user
@user = User.find(params[:id])
redirect_to(edit_user_path(@user)) unless @user == current_u... |
class AddComputingMinutesToExecutions < ActiveRecord::Migration
def change
add_column :executions, :computing_minutes, :integer
end
end
|
class AddRequiredFieldsToOngs < ActiveRecord::Migration
def change
change_column :ongs, :name, :string, :null => false
change_column :ongs, :description, :text, :null => false
change_column :ongs, :address, :text, :null => false
end
end
|
# For this challenge you will be capitalizing certain characters in a string.
puts "Enter a sentence: "
str = gets.chomp
arr = str.split
arr.each do |s|
s.capitalize!
end
str = arr.join(" ")
puts str |
Pod::Spec.new do |s|
s.name = "ETExtension" # 库名称
s.version = "1.0.0" # 库版本
s.summary = "自动解析XML节点的值并转换成对象。" # 简介
s.description = <<-DESC
仿MJExtension写的,自动解析XML数据。还有很多功能没有实现,只是为了方便自己。
DESC
s.homepage = "https://github.com/LarkNan/ETExtension" # 该... |
class MoveDiagnosisFieldsToPatientCase < ActiveRecord::Migration
def up
add_column :patient_cases, :disease_id, :integer
add_column :patient_cases, :severity, :integer, :default => 0
add_column :patient_cases, :revision, :boolean, :default => false
add_column :patient_cases, :body_part_id, :integer
... |
include RSpec
require_relative 'screen'
RSpec.describe Screen, type: Class do
let(:screen) { Screen.new(10, 10) }
describe "#insert" do
it "inserts a pixel at the proper x, y coordinates" do
p = Pixel.new(255, 255, 255, 1, 1)
screen.insert(p, 1, 1)
expect(screen.at(1, 1)).to eq p
end
... |
class EventsController < ApplicationController
def new
@event = Event.new
end
def create
@event = current_user.created_events.build(event_params)
if @event.save
flash.now[:success] = 'Event created!'
render :show
else
render :new
end
end
def show
@event = Event.find(params[:id])
@attendees ... |
class CreateCampaigns < ActiveRecord::Migration
def change
create_table :campaigns do |t|
t.text :name
t.text :digest
t.integer :source_id
end
create_table :events do |t|
t.text :name
t.integer :campaign_id
end
add_foreign_key :campaigns, :sources
add_foreign_ke... |
module Ui
class ConsoleStyle
def self.print_play_move(mark, move)
print_msg "play #{mark} #{move}"
end
def self.print_play_move_usage
print_msg 'usage: play $mark $move'
end
def self.print_board(board)
msg = "*===*\n"
board_string = board.to_s
(0...board_string.len... |
module Exceptions
class InvalidBrigadeProjectError < StandardError; end
end |
# required plugins: vagrant-hostmanager and vagrant-persistent-storage
vagrant_root = File.dirname(File.expand_path(__FILE__))
Vagrant.configure("2") do |config|
config.vm.box = "ceph-base"
config.ssh.forward_agent = true
config.ssh.insert_key = false
config.ssh.compression = false
# config.hostmanager.enabl... |
class AddTimestampToRssreader < ActiveRecord::Migration
def change
add_column "rssreader", "created_at", :datetime
add_column "rssreader", "updated_at", :datetime
end
end
|
Pod::Spec.new do |s|
s.name = 'UMessage'
s.version = '1.1.0'
s.summary = 'UMeng Push SDK'
s.homepage = 'http://dev.umeng.com/message/ios/sdk-download'
s.ios.deployment_target = '4.3'
s.source = { :git => "https://github.com/amoblin/easyPods.git", :branch => "master" }
s.source_files = "UMessage/UMessage.h... |
# Design a game
# HangMan - word guessing game
# PSEUDO CODE
# Create a class WordGame
# getter/setter methods?
# state/attributes (word, guess count, game over)
# behaviours (update and display feedback, end the game)
# USER INTERFACE
# prompt user for a word - player one
# initialize instance
# turn word into one... |
# frozen_string_literal: true
module NvGpuControl
module Util
# Augments {#`} to log commands and handle error cases
module Shell
# Raised on a shell error
class Error < RuntimeError
# @return [Process::Status] the process status
attr_reader :status
# @return [Array<Strin... |
class CustomersController < ApplicationController
# Want a reference to the currently logged in user before we run the edit/update process
# getting this via the session[:user_id]
before_filter :current_customer, :only => [ :edit, :show, :update]
def new
@customer = Customer.new
end
def create
@cus... |
require File.expand_path 'app/views/page/container.rb', Rails.root
require File.expand_path 'app/views/welcome/index/content.rb', Rails.root
# Class encapsulating all page-specific view code for `welcome/index`.
class Views::Welcome::Index < Views::BasePage
needs :posts
include Widgets::Page
include Widgets::W... |
#! env ruby
def toWinPath(wslPath)
cmd = "wslpath -w '#{wslPath}'"
return `#{cmd}`.strip
end
# This utility decompiles every pex file in the target_dir
# and places the result file in the same directory.
require('optparse')
require('pathname')
require('fileutils')
options = {}
optParser = OptionParser.new do |opt... |
module Admin
class TimelinesController < BaseController
load_and_authorize_resource :project
load_and_authorize_resource through: :project, shallow: true
def create
if @timeline.save
redirect_back fallback_location: [:admin, @project]
else
errors_to_flash(@project)
render 'new'
en... |
# == Schema Information
#
# Table name: players
#
# id :integer not null, primary key
# summonerid :string
# created_at :datetime not null
# updated_at :datetime not null
# name :string
# tier :string
# topchampionid :string
#
FactoryGirl.define do
... |
# TO BE REMOVED
module Inventory
class ItemSerializer
include FastJsonapi::ObjectSerializer
attributes :name, :quantity, :uom
end
end
|
class Map::ApplicationController < ActionController::Base
include Passwordless::ControllerHelpers
include Geokit::Geocoders
layout 'map/application'
before_action :setup_client!
before_action :setup_config!
def show
render 'map/show'
end
def embed
# response.headers["Expires"] = 1.day.from_... |
class EventVenue < ApplicationRecord
validates :name, :address, presence: true
validates :capacity, numericality: {greater_than_or_equal_to: 10, only_integer: true}
has_many :events
end
|
class AddDetailsToReview < ActiveRecord::Migration[5.1]
def change
add_column :reviews, :name, :string
add_column :reviews, :email, :string
add_column :reviews, :review, :string
add_column :reviews, :approved, :boolean
end
end
|
module Bs::SerializerHelper
def serialize_objects(*objects)
final_hash = {}
objects.each do |data|
serialize_options = {}
object = nil
if data.is_a?(Hash)
serialize_options = data[:options]
object = data[:data]
else
object = data
end
final_hash.merg... |
# frozen_string_literal: true
class Post < ApplicationRecord
belongs_to :user
belongs_to :framework
validates :title, presence: true, uniqueness: true
validates :body, presence: true
end
|
class UsersController < ApplicationController
before_action :authenticate_user!
before_action :only_current_user, except: [:index, :dashboard]
before_action :set_user, only: [:show, :edit, :destroy]
# before_action :correct_user, only: [:edit, :update, :destroy]
def index
# @user = User... |
require 'sinatra/jbuilder'
module JsonHelper
def render_json(*args)
content_type "application/json"
jbuilder *args
end
def not_found
content_type "application/json"
halt 404
end
end
|
# 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
#... |
require 'samanage'
@token = ARGV[0]
@datacenter = ARGV[1]
@samanage = Samanage::Api.new(token: @token, datacenter: @datacenter)
@samanage.users.each do |user|
user_needs_to_be_activated = !user['last_login'] && !user['disabled']
if user_needs_to_be_activated
begin
puts "Sending Activation to #{user['emai... |
class Company < ApplicationRecord
has_many :purchased_stocks
has_many :articles
has_many :watchlists
end
|
require 'spec_helper'
describe "UserPages" do
subject { page }
describe "register page" do
before { visit register_path }
it { should have_title('Register') }
it { should have_selector('h1', text: 'Register') }
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.