Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions app/components/donation-goals.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Ember from 'ember';
const {
Component,
computed: {
and, alias, bool, filterBy, not, notEmpty, setDiff, sort
alias, filterBy, not, notEmpty, setDiff, sort
}
} = Ember;

Expand Down Expand Up @@ -49,12 +49,10 @@ export default Component.extend({
/**
* Indicates if the user can activate donations for this project.
*
* This is possible if at least one donation goal has been added.
*
* @property canActivateDonations
* @type {Boolean}
*/
canActivateDonations: and('hasExistingDonationGoals', '_donationsInactive'),
canActivateDonations: alias('project.canActivateDonations'),

/**
* Indicates if the user can cancel adding or editing a donation goal.
Expand Down Expand Up @@ -86,8 +84,6 @@ export default Component.extend({
hasExistingDonationGoals: notEmpty('_existingDonationGoals'),

_currentlyEditingDonationGoals: notEmpty('_editedDonationGoals'),
_donationsActive: bool('project.stripeConnectPlan.id'),
_donationsInactive: not('_donationsActive'),
_editedDonationGoals: filterBy('project.donationGoals', 'isEditing'),
_existingDonationGoals: setDiff('project.donationGoals', '_newDonationGoals'),
_newDonationGoals: filterBy('project.donationGoals', 'isNew')
Expand Down
4 changes: 0 additions & 4 deletions app/controllers/project/settings/donations/goals.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ export default Controller.extend({
}
},

reloadAccount() {
get(this, 'stripeConnectAccount').reload();
},

/**
* Action which commits changes to a donation goal.
*
Expand Down
1 change: 1 addition & 0 deletions app/models/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { computed, computed: { alias, filterBy, gt }, get } = Ember;

export default Model.extend({
base64IconData: attr(),
canActivateDonations: attr(),
closedTasksCount: attr('number'),
description: attr(),
donationsActive: attr(),
Expand Down
2 changes: 1 addition & 1 deletion app/styles/components/project-menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
display: block;
font-weight: 500;
margin-bottom: -1px;
padding: 6px 14px;
padding: 6px 10px;
text-decoration: none;

&.active {
Expand Down
6 changes: 6 additions & 0 deletions app/templates/components/payments/account-setup.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@
stripeConnectAccount=stripeConnectAccount
submit=(action onBankAccountInformationSubmitted)
}}

{{#if project.canActivateDonations}}
<h3>Start taking donations</h3>
<p>Go set your donation goals and start accepting donations now.</p>
{{link-to 'Donations' 'project.settings.donations.goals' project class='button default activate-donations'}}
{{/if}}
1 change: 1 addition & 0 deletions app/templates/project/settings/donations/payments.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
onRecipientDetailsSubmitted=(action 'onRecipientDetailsSubmitted')
onVerificationDocumentSubmitted=(action 'onVerificationDocumentSubmitted')
organizationName=project.organization.name
project=project
stripeConnectAccount=stripeConnectAccount
}}

Expand Down
3 changes: 2 additions & 1 deletion tests/acceptance/project-donation-goals-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ test('it allows activating donations for the project', function(assert) {

let project = createProjectWithSluggedRoute();
let { organization } = project;
server.createList('donation-goal', 1, { project });
project.attrs.canActivateDonations = true;
project.save();

authenticateAsMemberOfRole(this.application, server, organization, 'owner');

Expand Down
16 changes: 4 additions & 12 deletions tests/integration/components/donation-goals-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,20 +248,16 @@ test('it calls provided "add" action with project as parameter when add button i
this.$('.add').click();
});

test('it allows activating donations if there are persisted records', function(assert) {
test('it allows activating donations if canActivateDonations is true', function(assert) {
assert.expect(2);

let mockGoals = [
Object.create({ isEditing: false, isLoaded: true, isNew: false })
];

function activateDonationsHandler() {
assert.ok(true, 'Action was called when button was clicked');
}

setHandlers(this, { activateDonationsHandler });

set(this, 'project', Object.create({ donationGoals: mockGoals }));
set(this, 'project', Object.create({ canActivateDonations: true }));

this.render(hbs`{{donation-goals activateDonations=activateDonationsHandler add=addHandler edit=editHandler project=project}}`);

Expand All @@ -270,14 +266,10 @@ test('it allows activating donations if there are persisted records', function(a
this.$('.activate-donations').click();
});

test('it prevents activating donations if there are no persisted records', function(assert) {
test('it prevents activating donations if canActivateDonations is false', function(assert) {
assert.expect(1);

let mockGoals = [
Object.create({ isEditing: false, isLoaded: true, isNew: true })
];

set(this, 'project', Object.create({ donationGoals: mockGoals }));
set(this, 'project', Object.create({ canActivateDonations: false }));

this.render(hbs`{{donation-goals add=addHandler edit=editHandler project=project}}`);

Expand Down
11 changes: 11 additions & 0 deletions tests/integration/components/payments/account-setup-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function renderPage() {
onRecipientDetailsSubmitted=onRecipientDetailsSubmitted
onVerificationDocumentSubmitted=onVerificationDocumentSubmitted
organizationName=project.organization.name
project=project
stripeConnectAccount=stripeConnectAccount
}}
`);
Expand Down Expand Up @@ -181,3 +182,13 @@ test('it works properly when account is fully verified', function(assert) {
assert.ok(page.rendersFundsRecipientVerified, 'Funds recipient component is rendered in verified state.');
assert.ok(page.rendersBankAccountVerified, 'Bank account component is rendered in verified state.');
});

test('it renders a link to set up donation goals when possible', function(assert) {
assert.expect(1);

this.set('project', { canActivateDonations: true });

renderPage();

assert.ok(page.rendersLinkToDonationGoals, 'Renders link to donation goals.');
});
2 changes: 2 additions & 0 deletions tests/pages/components/payments/account-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export default {
rendersFundsRecipientVerified: isVisible('.funds-recipient.account-setup__section--verified'),
rendersFundsRecipientVerifying: isVisible('.funds-recipient.account-setup__section--verifying'),

rendersLinkToDonationGoals: isVisible('a.activate-donations'),

createAccount,
bankAccount,
contactInfo,
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/models/project-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ test('it exists', function(assert) {
});

testForAttributes('project', [
'base64IconData', 'closedTasksCount', 'description', 'donationsActive',
'iconLargeUrl', 'iconThumbUrl', 'longDescriptionBody',
'longDescriptionMarkdown', 'openTasksCount', 'slug', 'title',
'totalMonthlyDonated'
'base64IconData', 'canActivateDonations', 'closedTasksCount',
'description', 'donationsActive', 'iconLargeUrl', 'iconThumbUrl',
'longDescriptionBody', 'longDescriptionMarkdown', 'openTasksCount',
'slug', 'title', 'totalMonthlyDonated'
]);

testForBelongsTo('project', 'organization');
Expand Down