FileRecord
- has many steps
- has and belongs to many tags
- has many assets - paperclip (el otro que no me acuerdo el nombre, algo con wave)
- belongs to topic (puede ser)
User
| class Plantilla | |
| attr_accessor :body, :title | |
| def initialize strategy | |
| self.strategy = strategy | |
| end | |
| def strategy= strategy | |
| @strategy = strategy.new(self) |
| test "shold return all file records that are currently in an office" do | |
| file_records = [file_records(:legal), file_records(:armas)] | |
| get :index, file_record: | |
| {q: {step_office_name_cont: 'Archivo'}} | |
| assert response.body == file_records.to_json | |
| end |
| class StepTest < ActiveSupport::TestCase | |
| test "create step with unexistant office" do | |
| step = Step.create name: 'Computo' | |
| assert step.office.name == 'Computo' | |
| end | |
| test "create step with existant office" do | |
| office = offices :computo | |
| step = Step.create office: office |
| require 'pry' | |
| class FoodChain | |
| ANIMALS = {'fly' => 'I don\'t know why she swallowed the fly. Perhaps she\'ll die.', | |
| 'spider' => 'that wriggled and jiggled and tickled inside her.', | |
| 'bird' => 'How absurd to swallow a bird!', | |
| 'cat' => 'Imagine that, to swallow a cat!', | |
| 'dog' => 'What a hog, to swallow a dog!', | |
| 'goat' => 'Just opened her throat and swallowed a goat!', |
| class SumOfMultiples | |
| attr_accessor :args | |
| def initialize *args | |
| self.args = args | |
| end | |
| def self.to n | |
| new(3,5).to n |
| class School | |
| def to_hash | |
| school.sort.to_h | |
| end | |
| def add name, grade | |
| if school[grade] | |
| (school[grade] << name).sort! | |
| else |
| class Series | |
| attr_accessor :series | |
| def initialize series | |
| self.series = series | |
| end | |
| def slices n | |
| raise ArgumentError.new("Length greater than series") if n > series.size |
| class PrimeFactors | |
| attr_accessor :n, :primes | |
| def initialize n | |
| self.n = n | |
| self.primes = prime_divisors | |
| end | |
| def self.for n |
| #!/usr/bin/env ruby | |
| gem 'minitest', '>= 5.0.0' | |
| require 'minitest/autorun' | |
| require_relative 'prime_factors' | |
| require 'pry' | |
| require 'prime' | |
| class PrimeFactorsTest < Minitest::Test | |
| def test_prime_factors |