Skip to content

Commit

Permalink
Added auth checks to all pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
yohanmishkin committed Apr 10, 2017
1 parent f2df92f commit 0378b66
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 22 deletions.
3 changes: 2 additions & 1 deletion app/controllers/disasters/disaster/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Ember from 'ember';

export default Ember.Controller.extend({
session: Ember.inject.service(),
gMap: Ember.inject.service(),
markers: Ember.computed.mapBy('model.sites', 'marker')
markers: Ember.computed.mapBy('model.sites', 'marker'),
});
1 change: 1 addition & 0 deletions app/controllers/disasters/disaster/sites/site/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Ember from 'ember';

export default Ember.Controller.extend({
session: Ember.inject.service(),
gMap: Ember.inject.service(),
markers: Ember.computed.mapBy('model.volunteers', 'marker')
});
2 changes: 1 addition & 1 deletion app/controllers/disasters/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Ember from 'ember';

export default Ember.Controller.extend({
session: Ember.inject.service('session')
session: Ember.inject.service()
});
17 changes: 14 additions & 3 deletions app/templates/disasters/disaster/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,21 @@
</div>
</div>
</div>
{{link-to 'Add another work site' 'disasters.disaster.sites.new' model class="another-site test-disaster-create-site"}}
{{/if}}

{{#if session.isAuthenticated}}
{{#if model.sites}}
{{link-to 'Add another work site' 'disasters.disaster.sites.new' model class="another-site test-disaster-create-site"}}
{{else}}
{{link-to 'Create first work site' 'disasters.disaster.sites.new' model class="test-disaster-create-site"}}
{{/if}}

{{roster-uploader}}
{{else}}
{{link-to 'Create first work site' 'disasters.disaster.sites.new' model class="test-disaster-create-site"}}
{{#link-to 'login'}}
<p class='login-link'>Please login to add sites and upload rosters</p>
{{/link-to}}
{{/if}}
{{roster-uploader}}


{{liquid-outlet}}
35 changes: 21 additions & 14 deletions app/templates/disasters/disaster/sites/site/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,26 @@

{{link-to 'Check in' 'disasters.disaster.sites.site.checkin' model.disaster.id model.id class='test-site-checkin'}}

{{#if model.volunteers}}
<hr>
<div class="card">
<div class="card-map test-map">
{{g-maps-fit name='volunteer-map' markers=markers class='volunteer-map test-volunteer-map'}}
{{#if session.isAuthenticated}}
{{#if model.volunteers}}
<hr>
<div class="card">
<div class="card-map test-map">
{{g-maps-fit name='volunteer-map' markers=markers class='volunteer-map test-volunteer-map'}}
</div>
</div>
<div class="card-header">
<h4>Roster</h4>
</div>
</div>
<div class="card-header">
<h4>Roster</h4>
</div>
<div class="card-copy test-roster">
{{#each model.volunteers as |volunteer|}}
{{roster-row volunteer=volunteer}}
{{/each}}
</div>
<div class="card-copy test-roster">
{{#each model.volunteers as |volunteer|}}
{{roster-row volunteer=volunteer}}
{{/each}}
</div>
{{/if}}
{{else}}
<hr>
{{#link-to 'login'}}
<p class='login-link'>Please login to view roster</p>
{{/link-to}}
{{/if}}
2 changes: 1 addition & 1 deletion app/templates/disasters/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{{#link-to "disasters.disaster" disaster}}
<li class='disaster'>{{disaster.name}}</li>
{{/link-to}}
{{/each}}}}
{{/each}}

{{#if session.isAuthenticated}}
{{#link-to 'disasters.new' class='test-disaster-create-new'}}
Expand Down
3 changes: 1 addition & 2 deletions tests/acceptance/disasters-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ moduleForAcceptance('Acceptance | disasters');

test('visiting /disasters, unauthenticated', function(assert) {
visit('/');

andThen(() => {
assert.equal(currentURL(), '/');
assert.ok(find('.login-link'), 'Login link appears');
Expand Down Expand Up @@ -84,10 +83,10 @@ test('quit creating new disaster and return to existing disasters', function(ass
});

test('can create work site', function(assert) {
authenticateSession(this.application);
let disaster = server.create('disaster', { name: 'Hurricane Charles' });

visit('/');

click('.test-disasters-list > a:first');

andThen(() => {
Expand Down
6 changes: 6 additions & 0 deletions tests/acceptance/sites-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import moduleForAcceptance from 'crosscheck/tests/helpers/module-for-acceptance'
import disasterPage from 'crosscheck/tests/pages/disaster';
import sitePage from 'crosscheck/tests/pages/site';
import checkinPage from 'crosscheck/tests/pages/checkin';
import { authenticateSession } from 'crosscheck/tests/helpers/ember-simple-auth';

const { Service } = Ember;

moduleForAcceptance('Acceptance | disasters/edit/sites');

test('Can navigate to site page', function(assert) {
authenticateSession(this.application);
let disaster = server.create('disaster', { name: 'Hurricane Daniel', slug: 'hurricane-daniel' });
let site = server.create('site', { name: 'Ticonderoga', location: '12 Candy Lane', disaster });

Expand All @@ -26,6 +28,7 @@ test('Can navigate to site page', function(assert) {
});

test('Volunteer can check into site', function(assert) {
authenticateSession(this.application);
let disaster = server.create('disaster', { name: 'Hurricane Daniel', slug: 'hurricane-daniel' });
let site = server.create('site', { name: 'Ticonderoga', location: '12 Candy Lane', disaster });

Expand Down Expand Up @@ -75,6 +78,7 @@ test('Volunteer can check into site', function(assert) {
});

test('Deactivates model if you navigate away from new site page', function(assert) {
authenticateSession(this.application);
let disaster = server.create('disaster');
server.create('site', { disaster });

Expand All @@ -92,6 +96,7 @@ test('Deactivates model if you navigate away from new site page', function(asser
});

test('View volunteers roster on site', function(assert) {
authenticateSession(this.application);
let volunteers = server.createList('volunteer', 1, {
name: "volunteerName",
status: 'statusCode',
Expand Down Expand Up @@ -168,6 +173,7 @@ test('No roster appears on site without volunteers', function(assert) {
});

test('View volunteer map on site page', function(assert) {
authenticateSession(this.application);
let volunteers = server.createList('volunteer', 1, {
latitude:40.7686973,
longitude:-73.9918181
Expand Down

0 comments on commit 0378b66

Please sign in to comment.