This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe "Viewing the list of movies" do | |
it "shows the movies" do | |
movie1 = Movie.create(title: "Iron Man", | |
rating: "PG-13", | |
total_gross: 318412101.00, | |
description: "Tony Stark builds an armored suit to fight the throes of evil", | |
released_on: "2008-05-02", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
# I spent 15 minutes creating a quick example for an email list... | |
describe "State" do | |
it 'has a list of states' do | |
State.respond_to?(:states) | |
expect(State.states).to have_key('AK') | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'dragonfly' | |
require 'dragonfly/mongo_data_store' | |
require 'mongo' | |
require 'uri' | |
# From https://devcenter.heroku.com/articles/mongohq#use-with-ruby | |
def get_connection | |
return @db_connection if @db_connection | |
db = URI.parse(ENV['MONGOHQ_URL']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Period | |
include MongoMapper::EmbeddedDocument | |
key :text, String | |
embedded_in :schedule | |
def to_s | |
text | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Quickly exercise the primary ADMIN UIs just to make sure nothing blows up | |
Background: We need to pre-populate the database with the simulator results, and be logged in as admin | |
Given I login as "admin" | |
And we have the following Patients: | |
| Johnson | | |
| Henry | | |
| Walters | | |
| Glanzmann | | |
| Franklin | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run this in mmconsole | |
class User | |
include MongoMapper::Document | |
key :name | |
key :role | |
def admin? | |
role.index(/admin/i) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node | |
include MongoMapper::Document | |
key :name | |
belongs_to :parent, :class_name => 'Node' | |
many :children, :class_name => 'Node' | |
def root? | |
parent.nil? | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.dirname(__FILE__) + '/../spec_helper' | |
describe "ResourceLog" do | |
@@debug = false | |
before :all do | |
puts "--------------------" | |
ResourceLog.destroy_all | |
ResourceLog.count().should == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
without a compound index | |
> db.accounts.find({state: "active"}).limit(15).sort({email: 1}).explain(); | |
{ | |
"cursor" : "BasicCursor", | |
"nscanned" : 11002, | |
"nscannedObjects" : 11002, | |
"n" : 15, | |
"scanAndOrder" : true, | |
"millis" : 44, | |
"nYields" : 0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MongoMapper.database.collection('users').drop | |
class User | |
include MongoMapper::Document | |
key :name, String, :required => true | |
end | |
User.destroy_all | |
text = [] | |
text << "After model with key :name, String" | |
text << User.keys.keys.inspect |
NewerOlder