This file contains hidden or 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 'rails_helper' | |
RSpec.describe Services::ReceiptDataSource do | |
describe "get_receipts" do | |
it "makes appropriate call to canonical data service" do | |
@subject_under_test = Services::ReceiptDataSource.new | |
@subject_under_test.get_receipts | |
expect(WebMock).to have_requested(:get, "#{ENV['RECEIPT_ENDPOINT']}/receipts.json") |
This file contains hidden or 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 'rails_helper' | |
RSpec.describe Services::ReceiptDataSource do | |
describe "equivalency" do | |
it "has all the methods present in the repository library" do | |
expect( | |
Repositories::ReceiptDataSource.instance_methods - Services::ReceiptDataSource.instance_methods | |
).to be_empty | |
end | |
end |
This file contains hidden or 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
RSpec.describe ReceiptDataSourceEquivalence do | |
before(:suite) do | |
@repository_receipt_data_source ||= Repositories::ReceiptDataSource.new(environment: Rails.env) | |
@service_receipt_data_source ||= Services::ReceiptDataSource.new(environment: Rails.env) | |
@local_records = @repository_receipt_data_source.all.collect(&:id) | |
@api_records = @service_receipt_data_source.all.collect(&:id) | |
@on_records = Array(@local_records & @api_records) | |
end |
This file contains hidden or 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 MembersController < ApplicationController | |
... | |
def index | |
@members = member_params.any? ? Member.where(member_params) : Member.all | |
json_options = params.fetch(:json_options, {}) | |
render json: @members.as_json(HashWithIndifferentAccess.new(json_options.permit!)) | |
end | |
This file contains hidden or 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 'uri' | |
require 'net/http' | |
class MemberService | |
def get_members(filters=Hash.new) | |
query_params = filters.to_query | |
uri = URI("https://bertrandshealthinsurance.com/members?#{query_params}") | |
request = Net::HTTP::Get.new(uri.path, {'Content-Type' => 'application/json'}) |
This file contains hidden or 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
POST request to 'awesomeprogrammers.com' | |
<Head> | |
<UserName>Ada Lovelace</UserName> | |
</Head> | |
<Body> | |
<Action>Login</Action> | |
<Password>WerdToThePass</Password> | |
</Body> |
This file contains hidden or 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
POST request to 'awesomeprogrammers.com/sessions' | |
{ | |
"userName": "Ada Lovelace", | |
"password":"WerdToThePass" | |
} |
This file contains hidden or 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
response to GET 'awesomeprogrammers.com/latanya_sweeney' | |
{ | |
"name" : "Latanya Sweeney", | |
"links" : [ | |
"summary" : { | |
"verb" : "GET", | |
"url" : "http://latanyasweeney.org", | |
"authenticate" : false | |
}, |
This file contains hidden or 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
from __future__ import unicode_literals | |
from django.conf import settings | |
from django.db import models | |
from django.utils import timezone | |
import numpy as np | |
from calendar import Calendar | |
from charts import HeatMap, PieChart |
This file contains hidden or 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
from __future__ import unicode_literals | |
from django.shortcuts import render | |
from models import Visualization | |
from exceptions import IncompleteDataException | |
from .forms import VisualizationForm | |
from django.contrib.auth.decorators import login_required | |
@login_required | |
def transform(request): |