parent
							
								
									dfe2c9cd74
								
							
						
					
					
						commit
						5ba3b125e8
					
				
					 7 changed files with 90 additions and 15 deletions
				
			
		| 
						 | 
					@ -19,11 +19,13 @@ export function testConfig() {
 | 
				
			||||||
  this.post('/species');
 | 
					  this.post('/species');
 | 
				
			||||||
  this.get('/species/:id');
 | 
					  this.get('/species/:id');
 | 
				
			||||||
  this.put('/species/:id');
 | 
					  this.put('/species/:id');
 | 
				
			||||||
 | 
					  this.delete('/species/:id');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  this.get('/characteristics');
 | 
					  this.get('/characteristics');
 | 
				
			||||||
  this.post('/characteristics');
 | 
					  this.post('/characteristics');
 | 
				
			||||||
  this.get('/characteristics/:id');
 | 
					  this.get('/characteristics/:id');
 | 
				
			||||||
  this.put('/characteristics/:id');
 | 
					  this.put('/characteristics/:id');
 | 
				
			||||||
 | 
					  this.delete('/characteristics/:id');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  this.get('/strains', function(db /*, request*/) {
 | 
					  this.get('/strains', function(db /*, request*/) {
 | 
				
			||||||
    return {
 | 
					    return {
 | 
				
			||||||
| 
						 | 
					@ -39,4 +41,5 @@ export function testConfig() {
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
  this.put('/strains/:id');
 | 
					  this.put('/strains/:id');
 | 
				
			||||||
 | 
					  this.delete('/strains/:id');
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,16 +1,23 @@
 | 
				
			||||||
import Ember from 'ember';
 | 
					import Ember from 'ember';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default Ember.Component.extend({
 | 
					const { Component } = Ember;
 | 
				
			||||||
  tagName: 'button',
 | 
					
 | 
				
			||||||
  classNames: ["button-red", "smaller", "delete"],
 | 
					export default Component.extend({
 | 
				
			||||||
 | 
					  tagName: 'span',
 | 
				
			||||||
  showConfirmDelete: false,
 | 
					  showConfirmDelete: false,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  click: function() {
 | 
					  actions: {
 | 
				
			||||||
    if (!this.get('showConfirmDelete')) {
 | 
					    initialClick: function() {
 | 
				
			||||||
      this.set('showConfirmDelete', true);
 | 
					      this.set('showConfirmDelete', true);
 | 
				
			||||||
    } else {
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    cancelDelete: function() {
 | 
				
			||||||
 | 
					      this.set('showConfirmDelete', false);
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    confirmDelete: function() {
 | 
				
			||||||
      this.attrs.delete();
 | 
					      this.attrs.delete();
 | 
				
			||||||
    }
 | 
					    },
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,12 @@
 | 
				
			||||||
{{#if showConfirmDelete}}
 | 
					{{#unless showConfirmDelete}}
 | 
				
			||||||
  Are you sure?
 | 
					  <button class="button-red smaller delete" {{action "initialClick"}}>
 | 
				
			||||||
 | 
					    Delete
 | 
				
			||||||
 | 
					  </button>
 | 
				
			||||||
{{else}}
 | 
					{{else}}
 | 
				
			||||||
  Delete
 | 
					  <button class="button-red smaller delete-confirm" {{action "confirmDelete"}}>
 | 
				
			||||||
{{/if}}
 | 
					    Confirm Delete
 | 
				
			||||||
 | 
					  </button>
 | 
				
			||||||
 | 
					  <button class="button-gray smaller delete-cancel" {{action "cancelDelete"}}>
 | 
				
			||||||
 | 
					    Cancel Delete
 | 
				
			||||||
 | 
					  </button>
 | 
				
			||||||
 | 
					{{/unless}}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,10 +6,10 @@ import { authenticateSession } from '../helpers/ember-simple-auth';
 | 
				
			||||||
module('Acceptance | characteristics', {
 | 
					module('Acceptance | characteristics', {
 | 
				
			||||||
  beforeEach: function() {
 | 
					  beforeEach: function() {
 | 
				
			||||||
    this.application = startApp();
 | 
					    this.application = startApp();
 | 
				
			||||||
 | 
					    server.create('users', { role: 'A', canEdit: true, sub: 1 });
 | 
				
			||||||
    authenticateSession(this.application, {
 | 
					    authenticateSession(this.application, {
 | 
				
			||||||
      access_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiYWN0ZGIiLCJzdWIiOiIxIiwiZXhwIjoxNDQ2NTAyMjI2LCJpYXQiOjE0NDY0OTg2MjZ9.vIjKHAsp2TkCV505EbtCo2xQT-2oQkB-Nv5y0b6E7Mg"
 | 
					      access_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiYWN0ZGIiLCJzdWIiOiIxIiwiZXhwIjoxNDQ2NTAyMjI2LCJpYXQiOjE0NDY0OTg2MjZ9.vIjKHAsp2TkCV505EbtCo2xQT-2oQkB-Nv5y0b6E7Mg"
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    server.create('users', { role: 'A', canEdit: true });
 | 
					 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  afterEach: function() {
 | 
					  afterEach: function() {
 | 
				
			||||||
| 
						 | 
					@ -70,3 +70,22 @@ test('creating /characteristics/new', function(assert) {
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test('deleting /characteristics/:id', function(assert) {
 | 
				
			||||||
 | 
					  const characteristic = server.create('characteristics', { 'canEdit': true });
 | 
				
			||||||
 | 
					  visit(`/characteristics/${characteristic.id}`);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  andThen(function() {
 | 
				
			||||||
 | 
					    assert.equal(currentURL(), `/characteristics/${characteristic.id}`);
 | 
				
			||||||
 | 
					    click('button.delete');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    andThen(function() {
 | 
				
			||||||
 | 
					      click('button.delete-confirm');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      andThen(function() {
 | 
				
			||||||
 | 
					        assert.equal(currentURL(), `/characteristics`);
 | 
				
			||||||
 | 
					        assert.equal(server.db.characteristics.length, 0);
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,10 +6,10 @@ import { authenticateSession } from '../helpers/ember-simple-auth';
 | 
				
			||||||
module('Acceptance | species', {
 | 
					module('Acceptance | species', {
 | 
				
			||||||
  beforeEach: function() {
 | 
					  beforeEach: function() {
 | 
				
			||||||
    this.application = startApp();
 | 
					    this.application = startApp();
 | 
				
			||||||
 | 
					    server.create('users', { role: 'A', canEdit: true, sub: 1 });
 | 
				
			||||||
    authenticateSession(this.application, {
 | 
					    authenticateSession(this.application, {
 | 
				
			||||||
      access_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiYWN0ZGIiLCJzdWIiOiIxIiwiZXhwIjoxNDQ2NTAyMjI2LCJpYXQiOjE0NDY0OTg2MjZ9.vIjKHAsp2TkCV505EbtCo2xQT-2oQkB-Nv5y0b6E7Mg"
 | 
					      access_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiYWN0ZGIiLCJzdWIiOiIxIiwiZXhwIjoxNDQ2NTAyMjI2LCJpYXQiOjE0NDY0OTg2MjZ9.vIjKHAsp2TkCV505EbtCo2xQT-2oQkB-Nv5y0b6E7Mg"
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    server.create('users', { role: 'A', canEdit: true });
 | 
					 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  afterEach: function() {
 | 
					  afterEach: function() {
 | 
				
			||||||
| 
						 | 
					@ -69,3 +69,22 @@ test('creating /species/new', function(assert) {
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test('deleting /species/:id', function(assert) {
 | 
				
			||||||
 | 
					  const species = server.create('species', { 'canEdit': true });
 | 
				
			||||||
 | 
					  visit(`/species/${species.id}`);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  andThen(function() {
 | 
				
			||||||
 | 
					    assert.equal(currentURL(), `/species/${species.id}`);
 | 
				
			||||||
 | 
					    click('button.delete');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    andThen(function() {
 | 
				
			||||||
 | 
					      click('button.delete-confirm');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      andThen(function() {
 | 
				
			||||||
 | 
					        assert.equal(currentURL(), `/species`);
 | 
				
			||||||
 | 
					        assert.equal(server.db.species.length, 0);
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,10 +6,10 @@ import { authenticateSession } from '../helpers/ember-simple-auth';
 | 
				
			||||||
module('Acceptance | strains', {
 | 
					module('Acceptance | strains', {
 | 
				
			||||||
  beforeEach: function() {
 | 
					  beforeEach: function() {
 | 
				
			||||||
    this.application = startApp();
 | 
					    this.application = startApp();
 | 
				
			||||||
 | 
					    server.create('users', { role: 'A', canEdit: true, sub: 1 });
 | 
				
			||||||
    authenticateSession(this.application, {
 | 
					    authenticateSession(this.application, {
 | 
				
			||||||
      access_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiYWN0ZGIiLCJzdWIiOiIxIiwiZXhwIjoxNDQ2NTAyMjI2LCJpYXQiOjE0NDY0OTg2MjZ9.vIjKHAsp2TkCV505EbtCo2xQT-2oQkB-Nv5y0b6E7Mg"
 | 
					      access_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiYWN0ZGIiLCJzdWIiOiIxIiwiZXhwIjoxNDQ2NTAyMjI2LCJpYXQiOjE0NDY0OTg2MjZ9.vIjKHAsp2TkCV505EbtCo2xQT-2oQkB-Nv5y0b6E7Mg"
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    server.create('users', { role: 'A', canEdit: true });
 | 
					 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  afterEach: function() {
 | 
					  afterEach: function() {
 | 
				
			||||||
| 
						 | 
					@ -74,3 +74,23 @@ test('creating /strains/new', function(assert) {
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test('deleting /strains/:id', function(assert) {
 | 
				
			||||||
 | 
					  const species = server.create('species');
 | 
				
			||||||
 | 
					  const strain = server.create('strains', { canEdit: true , species: species.id });
 | 
				
			||||||
 | 
					  visit(`/strains/${strain.id}`);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  andThen(function() {
 | 
				
			||||||
 | 
					    assert.equal(currentURL(), `/strains/${strain.id}`);
 | 
				
			||||||
 | 
					    click('button.delete');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    andThen(function() {
 | 
				
			||||||
 | 
					      click('button.delete-confirm');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      andThen(function() {
 | 
				
			||||||
 | 
					        assert.equal(currentURL(), `/strains`);
 | 
				
			||||||
 | 
					        assert.equal(server.db.strains.length, 0);
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,10 +6,10 @@ import { invalidateSession, authenticateSession } from '../helpers/ember-simple-
 | 
				
			||||||
module('Acceptance | users', {
 | 
					module('Acceptance | users', {
 | 
				
			||||||
  beforeEach: function() {
 | 
					  beforeEach: function() {
 | 
				
			||||||
    this.application = startApp();
 | 
					    this.application = startApp();
 | 
				
			||||||
 | 
					    server.create('users', { role: 'A', canEdit: true, sub: 1 });
 | 
				
			||||||
    authenticateSession(this.application, {
 | 
					    authenticateSession(this.application, {
 | 
				
			||||||
      access_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiYWN0ZGIiLCJzdWIiOiIxIiwiZXhwIjoxNDQ2NTAyMjI2LCJpYXQiOjE0NDY0OTg2MjZ9.vIjKHAsp2TkCV505EbtCo2xQT-2oQkB-Nv5y0b6E7Mg"
 | 
					      access_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiYWN0ZGIiLCJzdWIiOiIxIiwiZXhwIjoxNDQ2NTAyMjI2LCJpYXQiOjE0NDY0OTg2MjZ9.vIjKHAsp2TkCV505EbtCo2xQT-2oQkB-Nv5y0b6E7Mg"
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    server.create('users', { role: 'A', canEdit: true });
 | 
					 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  afterEach: function() {
 | 
					  afterEach: function() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Reference in a new issue