Skip to content

Commit

Permalink
I think this works
Browse files Browse the repository at this point in the history
  • Loading branch information
pikesley committed Jan 30, 2016
1 parent 98bb8a5 commit 072e0d5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class ApiController < ApplicationController
skip_before_filter :verify_authenticity_token
# http_basic_authenticate_with name: "#{ENV['API_USER']}", password: "#{ENV['API_PASSWORD']}"
http_basic_authenticate_with name: "#{ENV['API_USER']}", password: "#{ENV['API_PASSWORD']}"

def create
data = params['data']
Expand Down
11 changes: 9 additions & 2 deletions spec/controllers/api_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
describe ApiController, type: :controller do
describe 'POST #create' do
before :each do
DatabaseCleaner.clean
user = ENV['API_USER']
pw = ENV['API_PASSWORD']
request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(user,pw)
end

context 'with valid attributes' do
it 'creates a new glucose measurement' do
DatabaseCleaner.clean

expect {
post :create, data: {
"id":"3648",
Expand Down Expand Up @@ -45,6 +50,8 @@
"value"=>"6.0"
}.to_json
}.to change(MedicationEvent, :count).by 1

expect(MedicationEvent.first.insulin).to eq 'humalog'
end
end
end
Expand Down

0 comments on commit 072e0d5

Please sign in to comment.