Skip to content

Commit 4cbf630

Browse files
authored
Merge pull request #148 from openmcac/ac_select_speakers
Create bulletins with a sermon
2 parents 7447c4e + 52d8bbe commit 4cbf630

File tree

7 files changed

+68
-36
lines changed

7 files changed

+68
-36
lines changed

app/routes/bulletins/new.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
1313
name: 'Sunday Worship Service',
1414
description: publishedAt.format('MMMM Do YYYY, h:mm a'),
1515
serviceOrder: '',
16-
group: group
16+
group: group,
17+
sermon: this.store.createRecord("sermon")
1718
});
1819

1920
const filter = { latest_for_group: group.get('id') };

app/templates/bulletin/edit.hbs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
clearbanner=(action "clearBanner")
77
diduploadaudio=(action "didUploadAudio")
88
diduploadbanner=(action "didUploadBanner")
9-
includesermon=true
109
onsave=(action "saveBulletin")
1110
removeannouncement=(action "removeAnnouncement")
1211
reorderannouncements=(action "reorderAnnouncements")}}

app/templates/components/bulletin-editor.hbs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,18 @@
4444
rows="10"}}
4545
</div>
4646
</div>
47-
{{#if this.attrs.includesermon}}
48-
<div class="panel panel-default">
49-
<fieldset>
50-
<div class="panel-heading">
51-
<h3 class="panel-title">Sermon</h3>
52-
</div>
53-
<div class="panel-body">
54-
{{sermon-editor sermon=bulletin.sermon
55-
diduploadaudio=(action this.attrs.diduploadaudio)
56-
clearaudio=(action this.attrs.clearaudio)}}
57-
</div>
58-
</fieldset>
59-
</div>
60-
{{/if}}
47+
<div class="panel panel-default">
48+
<fieldset>
49+
<div class="panel-heading">
50+
<h3 class="panel-title">Sermon</h3>
51+
</div>
52+
<div class="panel-body">
53+
{{sermon-editor sermon=bulletin.sermon
54+
diduploadaudio=(action this.attrs.diduploadaudio)
55+
clearaudio=(action this.attrs.clearaudio)}}
56+
</div>
57+
</fieldset>
58+
</div>
6159
</section>
6260
{{#if this.attrs.appendannouncement}}
6361
<section class="announcements col-md-6">

mirage/config.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1+
import Mirage from "ember-cli-mirage";
2+
13
export default function() {
4+
this.post("/api/auth/sign_in", function(schema, request) {
5+
const user = schema.users.find(1);
6+
return new Mirage.Response(
7+
200,
8+
{ "access-token": "adssafsdafsdsfd", "client": "asdfasdfasafs", "uid": "[email protected]" },
9+
{"data":{"id":`${user.id}`,"type":"users","links":{"self":`/api/v1/users/${user.id}`},"attributes":{"name":user.name,"email":user.email}}}
10+
);
11+
});
12+
213
this.namespace = "/api/v1";
314

415
this.delete("/announcements/:id");
5-
this.get("/announcements");
616
this.get("/announcements/:id");
717
this.patch("/announcements/:id");
818
this.post("/announcements");
919

10-
this.get("/bulletins");
1120
this.get("/bulletins/:id");
1221
this.get("/bulletins/:id/sermon");
1322
this.patch("/bulletins/:id");
@@ -23,6 +32,24 @@ export default function() {
2332
this.patch("/sermons/:id");
2433
this.post("/sermons");
2534

35+
this.get("/bulletins", function(schema, request) {
36+
if (schema.bulletins.all().models.length > 0 &&
37+
request.queryParams["filter[latest_for_group]"]) {
38+
return schema.bulletins.find([1]);
39+
}
40+
41+
return schema.bulletins.all();
42+
});
43+
44+
this.get("/announcements", function(schema, request) {
45+
if (schema.announcements.all().models.length > 0 &&
46+
request.queryParams["filter[latest_for_group]"]) {
47+
return schema.announcements.find([1, 2, 3]);
48+
}
49+
50+
return schema.announcements.all();
51+
});
52+
2653
this.get("/posts", function(schema, request) {
2754
const groupId = request.queryParams["filter[group]"];
2855

mirage/scenarios/default.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ export default function(server) {
2222
}
2323

2424
server.createList("post", 10, { group: englishService });
25+
26+
server.create("user", { email: "[email protected]", name: "Test User" });
2527
}

tests/acceptance/bulletins/new-test.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,26 @@ test("it can create a new bulletin", assert => {
3838
serviceOrder: "New service order"
3939
};
4040

41+
const sermon = {
42+
name: "My Sermon",
43+
notes: "",
44+
series: "Super series",
45+
speaker: "Mr. Speaker"
46+
};
47+
4148
page.
4249
visit({ groupSlug: group.slug }).
4350
fillName(bulletin.name).
4451
fillPublishedAt(bulletin.publishedAt).
45-
fillServiceOrder(bulletin.serviceOrder).
46-
submit();
52+
fillServiceOrder(bulletin.serviceOrder);
53+
54+
page.sermonEditor.
55+
fillName(sermon.name).
56+
fillNotes(sermon.notes).
57+
fillSeries(sermon.series).
58+
fillSpeaker(sermon.speaker);
59+
60+
page.submit();
4761

4862
andThen(() => {
4963
const bulletins = server.db.bulletins;
@@ -59,25 +73,14 @@ test("it can create a new bulletin", assert => {
5973
test("it populates default values", assert => {
6074
authenticateSession(application, sessionData);
6175

62-
const group = server.create("group");
63-
page.visit({ groupSlug: group.slug });
64-
65-
andThen(() => {
66-
assert.equal(page.name, "Sunday Worship Service");
67-
assert.equal(page.serviceOrder, "");
68-
equalDate(assert, page.publishedAt, nextService());
69-
});
70-
});
71-
72-
test("it defaults to last week's service order when available", assert => {
73-
authenticateSession(application, sessionData);
74-
7576
const group = server.create("group");
7677
const lastWeekBulletin = server.create("bulletin", { group });
7778

7879
page.visit({ groupSlug: group.slug });
7980

8081
andThen(() => {
82+
assert.equal(page.name, "Sunday Worship Service");
83+
equalDate(assert, page.publishedAt, nextService());
8184
assert.equal(page.serviceOrder, lastWeekBulletin.serviceOrder);
8285
});
8386
});

tests/pages/new-bulletin.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import PageObject from '../page-object';
2+
import sermonEditor from "mcac/tests/pages/components/sermon-editor";
23

34
const { visitable, fillable, clickable } = PageObject;
45

56
export default PageObject.create({
6-
visit: visitable("/:groupSlug/bulletins/new"),
77
fillName: fillable(selector("name")),
88
fillPublishedAt: fillable(`${selector("published-at")} input`),
99
fillServiceOrder: fillable(selector("service-order")),
10-
submit: clickable('button[type=submit]'),
1110
name: PageObject.value(selector("name")),
1211
publishedAt: PageObject.value(`${selector("published-at")} input`),
13-
serviceOrder: PageObject.value(selector("service-order"))
12+
sermonEditor,
13+
serviceOrder: PageObject.value(selector("service-order")),
14+
submit: clickable('button[type=submit]'),
15+
visit: visitable("/:groupSlug/bulletins/new")
1416
});
1517

1618
function selector(s) {

0 commit comments

Comments
 (0)