Skip to content

Commit

Permalink
Upgrading to mongoid 3.0.6, the latest health-data-standards and devi…
Browse files Browse the repository at this point in the history
…se_oauth2_providable code
  • Loading branch information
eedrummer committed Sep 21, 2012
1 parent 9c5e0c4 commit 01009eb
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 82 deletions.
10 changes: 4 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@ source 'http://rubygems.org'


gem 'rails', '3.2.8'
gem "health-data-standards", :git => "http://github.com/projectcypress/health-data-standards.git", :branch => "develop"
gem "health-data-standards", :git => "https://github.com/eedrummer/health-data-standards.git", :branch => "develop"
gem 'ruby-openid'
gem "mongoid"
gem "bson_ext"
gem "mongoid", '~> 3.0.6'
gem "pry"
gem 'pry-nav'
gem "capistrano"
gem 'heroku'
gem "nokogiri"
gem "nokogiri", '~> 1.5.5'
gem 'devise'
gem 'devise_oauth2_providable', :git => 'http://github.com/rdingwell/devise_oauth2_providable.git' #,:branch => "master"
gem 'devise_oauth2_providable', :git => 'https://github.com/project-rhex/devise_oauth2_providable.git' #,:branch => "master"
gem 'omniauth_openid_connect', :git => "https://github.com/project-rhex/omniauth_openid_connect.git"

gem 'omniauth'
Expand Down
55 changes: 19 additions & 36 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
GIT
remote: http://github.com/projectcypress/health-data-standards.git
revision: e2a73f19322e6ef9115e932dbba9b11751afa745
remote: https://github.com/eedrummer/health-data-standards.git
revision: efd8445676b1ff0575f3c617cd54f4b6d791a7fc
branch: develop
specs:
health-data-standards (1.0.1)
health-data-standards (2.0.0)
builder (~> 3.0.0)
erubis (~> 2.6)
mongoid (~> 2.4.2)
nokogiri (>= 1.4.4)
uuid (~> 2.3.4)
erubis (~> 2.7.0)
mongoid (~> 3.0.6)
nokogiri (~> 1.5.5)
uuid (~> 2.3.5)

GIT
remote: http://github.com/rdingwell/devise_oauth2_providable.git
revision: 99d0ca56786f86a8e28875d462c99f9e344ac2f9
remote: https://github.com/project-rhex/devise_oauth2_providable.git
revision: 1e3b7f5553e0b5b957b876fa8e42a593c7ebaa32
specs:
devise_oauth2_providable (1.0.5)
devise (>= 1.4.3)
Expand Down Expand Up @@ -63,9 +63,6 @@ GEM
arel (3.0.2)
attr_required (0.0.5)
bcrypt-ruby (3.0.1)
bson (1.7.0)
bson_ext (1.7.0)
bson (~> 1.7.0)
builder (3.0.3)
capistrano (2.13.4)
highline
Expand Down Expand Up @@ -96,7 +93,6 @@ GEM
warden (~> 1.2.1)
erubis (2.7.0)
eventmachine (1.0.0)
excon (0.16.2)
execjs (1.4.0)
multi_json (~> 1.0)
factory_girl (4.1.0)
Expand All @@ -112,14 +108,6 @@ GEM
nokogiri (> 0.0.0)
sax-machine (>= 0.0.12)
hashie (1.2.0)
heroku (2.31.2)
heroku-api (~> 0.3.4)
launchy (>= 0.3.2)
netrc (~> 0.7.7)
rest-client (~> 1.6.1)
rubyzip
heroku-api (0.3.5)
excon (~> 0.16.1)
highline (1.6.15)
hike (1.2.1)
httpclient (2.2.7)
Expand All @@ -128,6 +116,7 @@ GEM
jquery-rails (2.1.2)
railties (>= 3.1.0, < 5.0)
thor (~> 0.14)
jruby-pageant (1.1.1)
json (1.7.5)
json-jwt (0.1.8)
activesupport (>= 2.3)
Expand All @@ -137,8 +126,6 @@ GEM
kaminari (0.14.1)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
launchy (2.1.2)
addressable (~> 2.3)
libv8 (3.3.10.4)
loofah (1.2.1)
nokogiri (>= 1.4.4)
Expand All @@ -151,21 +138,21 @@ GEM
method_source (0.8)
mime-types (1.19)
minitest (3.4.0)
mongo (1.3.1)
bson (>= 1.3.1)
mongoid (2.4.12)
mongoid (3.0.6)
activemodel (~> 3.1)
mongo (<= 1.6.2)
moped (~> 1.1)
origin (~> 1.0)
tzinfo (~> 0.3.22)
moped (1.2.2)
multi_json (1.3.6)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-sftp (2.0.5)
net-ssh (>= 2.0.9)
net-ssh (2.5.2)
net-ssh (2.6.0)
jruby-pageant (>= 1.1.1)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
netrc (0.7.7)
nokogiri (1.5.5)
omniauth (1.1.1)
hashie (~> 1.2)
Expand All @@ -183,6 +170,7 @@ GEM
tzinfo
validate_email
validate_url
origin (1.0.8)
orm_adapter (0.4.0)
polyglot (0.3.3)
pry (0.9.10)
Expand Down Expand Up @@ -226,10 +214,7 @@ GEM
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
rest-client (1.6.7)
mime-types (>= 1.16)
ruby-openid (2.2.0)
rubyzip (0.9.9)
sass (3.2.1)
sass-rails (3.2.5)
railties (~> 3.2.0)
Expand Down Expand Up @@ -286,7 +271,6 @@ PLATFORMS
ruby

DEPENDENCIES
bson_ext
capistrano
coffee-rails (~> 3.2.1)
cover_me
Expand All @@ -295,12 +279,11 @@ DEPENDENCIES
factory_girl_rails
feedzirra
health-data-standards!
heroku
jquery-rails
kaminari
minitest
mongoid
nokogiri
mongoid (~> 3.0.6)
nokogiri (~> 1.5.5)
omniauth
omniauth-openid
omniauth_openid_connect!
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def add_breadcrumb title, link = nil
# parameter. Make sure to add exceptions for methods that don't.
def find_record
record_id = params[:record_id] || params[:id]
@record = Record.first(conditions: {medical_record_number: record_id})
@record = Record.where(medical_record_number: record_id).first
raise RequestError.new(404) if @record.nil?
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/entries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def set_up_section
end

def find_entry
if BSON::ObjectId.legal?(params[:id])
@entry = @record.send(@section_name).find(:first, conditions: {id: params[:id]})
if Moped::BSON::ObjectId.legal?(params[:id])
@entry = @record.send(@section_name).where(id: params[:id]).first
raise RequestError.new(404, 'Entry Not Found') unless @entry
else
raise RequestError.new(400, 'Not a valid identifier for a section document')
Expand Down
14 changes: 5 additions & 9 deletions app/controllers/open_id_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,8 @@ def authorize

scope = scope.split(/\s/)

# Find or create a client that matches the given client id
begin
client = Devise::Oauth2Providable::Client.first(conditions: {cidentifier: client_id})
rescue
#
end

client = Devise::Oauth2Providable::Client.where(cidentifier: client_id).first

unless client
raise OpenId::AuthenticationException.new(value: OpenId::ErrorCodes::INVALID_REQUEST,
Expand Down Expand Up @@ -101,8 +97,8 @@ def validate
end

# Find client and user
user = User.first(conditions: {email: credentials[:email]})
client = Devise::Oauth2Providable::Client.first(conditions: {cidentifier: client_id})
user = User.find_by(email: credentials[:email])
client = Devise::Oauth2Providable::Client.where(cidentifier: client_id).first

unless client
raise Exception.new("Client is missing from the database")
Expand Down Expand Up @@ -154,7 +150,7 @@ def confirm
description: "The user denied access to the website", redirect_uri: redirect_uri, state: state)
end

client = Devise::Oauth2Providable::Client.first(conditions: {cidentifier: client_id})
client = Devise::Oauth2Providable::Client.where(cidentifier: client_id).first

# Create and store the code in the client along with the scopes the user has enabled
code = SecureRandom.uuid
Expand Down
4 changes: 2 additions & 2 deletions app/models/audit_log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ class AuditLog
## get list of all audited docs
def self.review_docs()
## return all log events that end in _access
AuditLog.all( conditions: { event: /_access$/i } ).to_a
AuditLog.where(event: /_access$/i).to_a
end


## get list of audited docs with this id
def self.review_doc(id)
## query and return array of data
AuditLog.all( conditions: { event: /_access$/i, obj_id: id } ).to_a
AuditLog.where(event: /_access$/i).where(obj_id: id).to_a
end


Expand Down
4 changes: 2 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class User
:oauth2_authorization_code_grantable

## Database authenticatable
field :email, type: String, null: false
field :encrypted_password, type: String, null: false
field :email, type: String
field :encrypted_password, type: String

## Recoverable
field :reset_password_token, type: String
Expand Down
25 changes: 15 additions & 10 deletions config/mongoid.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
development:
host: localhost
database: hdata_server_development
sessions:
default:
database: patient_data_server_development
hosts:
- localhost:27017

test:
host: <%= ENV['TEST_DB_HOST'] || 'localhost' %>
database: hdata_server_test

staging:
host: localhost
database: hdata_server_staging
sessions:
default:
database: patient_data_server_test
hosts:
- <%= ENV['TEST_DB_HOST'] || 'localhost' %>:27017

production:
host: localhost
database: hdata_server_production
sessions:
default:
database: patient_data_server_production
hosts:
- localhost:27017
2 changes: 1 addition & 1 deletion lib/notify/notify_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class NotifyEvent

def self.process(user, action)
# lookup user and action in notify_config
notify_configs = NotifyConfig.all( conditions: { user: /#{user}/i, action: action } ).to_a
notify_configs = NotifyConfig.where(user: /#{user}/i, action: action).to_a

# for each entry, insert a document into notification table
notify_configs.each do |nconfig|
Expand Down
12 changes: 2 additions & 10 deletions test/functional/audit_review_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,15 @@ class AuditReviewControllerTest < ActionController::TestCase
test "audit_review_docs" do
assert_not_nil @audit_log, "factory girl audit_log is nil"







## get test obj_id
test_id = @audit_log.obj_id

## get list of all review docs (docs that end in _access)
review_docs = AuditLog.review_docs
assert_not_nil review_docs, "review_docs query failed"

assert_equal review_docs.count, 3, "audit_log not populated correctly"
assert_equal review_docs[0].obj_id, test_id, "obj_id is not #{test_id} (1)"
assert_equal 3, review_docs.count, "audit_log not populated correctly"
assert_equal test_id, review_docs[0].obj_id, "obj_id is not #{test_id} (1)"

## get this specific doc
review_docs = AuditLog.review_doc(test_id)
Expand All @@ -65,8 +59,6 @@ class AuditReviewControllerTest < ActionController::TestCase
@record.save
AuditLog.doc("NONE", "c32_access", "test description", @record, @record.version)
#
#
#

review_docs = AuditLog.review_doc(@record._id)
assert_not_nil review_docs, "review_doc query failed(2)"
Expand Down
2 changes: 1 addition & 1 deletion test/functional/open_id_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class OpenIdControllerTest < ActionController::TestCase
CLIENT_ID = '1570981427089'

def setup
@client = Devise::Oauth2Providable::Client.first(conditions: {cidentifier: CLIENT_ID})
@client = Devise::Oauth2Providable::Client.find_by(cidentifier: CLIENT_ID)
@client = FactoryGirl.create(:client) unless @client
@user = FactoryGirl.create(:user)
sign_in @user
Expand Down
2 changes: 1 addition & 1 deletion test/integration/notification_event_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class NotificationEventTest < ActionController::TestCase
NotifyEvent.process("[email protected]", :record_update)
notifications = Notification.all.to_a
assert_not_nil notifications, "Notifications is null !"
assert_equal notifications.count, 1, "notifications not populated correctly"
assert_equal 1, notifications.count, "notifications not populated correctly"
end


Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def load_fixtures


def dump_database
Mongoid::Config.master.collections.each do |collection|
Mongoid.session(:default).collections.each do |collection|
collection.drop unless collection.name.include?('system.')
end
end
Expand Down

0 comments on commit 01009eb

Please sign in to comment.