Sha256: ec0e73f70a6786d80b938da94dbd9b2336949b0644c8627459eec3cffe2caf1a
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
require 'spec_helper' describe G5Updatable::SyncsController, type: :controller do routes { G5Updatable::Engine.routes } describe 'GET index' do let(:client) { create(:client) } let!(:location) { create(:incrementing_location, client: client) } let!(:location2) { create(:incrementing_location, client: client) } let!(:location3) { create(:incrementing_location, client: client) } subject(:index) { safe_get :index, params } let(:json) { JSON.parse(response.body) } describe 'valid request' do let(:params) { { urn: client.urn } } it { is_expected.to be_successful } it 'returns the formatted time of the last update' do time_format = '%I:%M%P on %B %e, %Y' time_string = location2.updated_at.in_time_zone.strftime(time_format) index expect(json['updated_at']).to eq(time_string) end end describe 'invalid client' do let(:params) { { urn: 'xxx' } } it 'raises an error' do # This error will cause rails to return a 404 in production expect { index }.to raise_error(ActiveRecord::RecordNotFound) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
g5_updatable-1.0.2.pre.1 | spec/controllers/syncs_controller_spec.rb |