Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Coquereau committed Feb 6, 2014
2 parents 80a67a9 + f60d5c7 commit 4fc5c77
Show file tree
Hide file tree
Showing 16 changed files with 4,548 additions and 185 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/node_modules
/vendor/*
!/vendor/loader.js
!/vendor/sinon.js

# misc
/.sass-cache
Expand Down
70 changes: 51 additions & 19 deletions api-stub/routes.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,63 @@
module.exports = function(server) {

// Create an API namespace, so that the root does not
// Create an API namespace, so that the root does not
// have to be repeated for each end point.
server.namespace('/api', function() {

// Return fixture data for '/api/posts/:id'
server.get('/posts/:id', function(req, res) {
var post = {
"post": {
"id": 1,
"title": "Rails is omakase",
"comments": ["1", "2"],
"user" : "dhh"
},
server.get('/mailboxes/', function(req, res) {

"comments": [{
"id": "1",
"body": "Rails is unagi"
}, {
"id": "2",
"body": "Omakase O_o"
}]
};
var data = {
"mailboxes": [{
"name": "Inbox",
"id": "inbox",
"messages": ["1", "2"]
}, {
"name": "Spam",
"id": "spam",
"messages": ["3"]
}, {
"name": "Sent Mail",
"id": "sent-mail",
"messages": ["4"]
}],

res.send(post);
"messages": [{
"id": 1,
"subject": "Welcome to Ember",
"from": "[email protected]",
"to": "[email protected]",
"date": new Date(),
"body": "Welcome to Ember. We hope you enjoy your stay"
}, {
"id": 2,
"subject": "Great Ember Resources",
"from": "[email protected]",
"to": "[email protected]",
"date": new Date(),
"body": "Have you seen embercasts.com? How about emberaddons.com?"
},
{
"id": 3,
"subject": "You have one the lottery!!!111ONEONE",
"from": "[email protected]",
"to": "[email protected]",
"date": new Date(),
"body": "You have ONE the lottery! You only have to send us a small amount of monies to claim your prize"
},
{
"id": 4,
"subject": "Should I use Ember",
"from": "[email protected]",
"to": "[email protected]",
"date": new Date(),
"body": "Ember looks pretty good, should I use it?"
}]
};

res.send(data);
});

});

};
};
9 changes: 8 additions & 1 deletion app/adapters/application.js
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
export default DS.FixtureAdapter.extend();
// Application adapter
// ===================

var ApplicationAdapter = DS.RESTAdapter.extend({
namespace: 'api'
});

export default ApplicationAdapter;
41 changes: 19 additions & 22 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- build:css(tmp/result) /assets/app.min.css -->
<!-- @if tests=false -->
<link rel="stylesheet" href="/assets/app.css">
<!-- @endif -->
<!-- @if tests=true -->
<link rel="stylesheet" href="/vendor/mocha/mocha.css">
<!-- @endif -->
<!-- endbuild -->

<!-- for more details visit: https://github.com/yeoman/grunt-usemin -->
Expand Down Expand Up @@ -38,6 +43,7 @@
<!-- @if dist=false -->
<script src="/vendor/handlebars/handlebars.js"></script>
<script src="/vendor/ember/ember.js"></script>
<script src="/vendor/ember-data/ember-data.js"></script>
<!-- @endif --><!-- @if dist=true -->
<script src="/vendor/handlebars/handlebars.runtime.js"></script>
<script src="/vendor/ember/ember.prod.js"></script>
Expand All @@ -57,29 +63,18 @@
<!-- endbuild -->

<!-- @if tests=true -->
<link rel="stylesheet" href="/vendor/qunit/qunit/qunit.css">
<script src="/vendor/qunit/qunit/qunit.js"></script>

<style>
#ember-testing-container {
position: absolute;
background: white;
bottom: 0;
right: 0;
width: 640px;
height: 384px;
overflow: auto;
z-index: 9999;
border: 1px solid #ccc;
}
#ember-testing {
zoom: 50%;
}
</style>
<!--<link rel="stylesheet" href="/vendor/qunit/qunit/qunit.css">
<script src="/vendor/qunit/qunit/qunit.js"></script>-->
<script src="/vendor/mocha/mocha.js"></script>
<script src="/vendor/chai/chai.js"></script>
<script src="/vendor/sinon.js"></script>
<script src="/vendor/ember-mocha-adapter/adapter.js"></script>
<script>Ember.Test.adapter = Ember.Test.MochaAdapter.create();</script>
<!-- @endif -->

</head>
<body class="index">
<!-- @if tests=false -->
<!--[if lt IE 8]>
<p class="browsehappy">
You are using an <strong>outdated</strong> browser. Please
Expand All @@ -98,14 +93,16 @@
</div>
</div>
</div>

<!-- @endif -->
<!-- @if tests=true -->
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<div id="mocha"></div>
<div id="ember-testing"></div>

<script src="/tests/tests.js"></script>
<script src="/tests/test_helper.js"></script>
<script src="/tests/test_loader.js"></script>
<script src="/testem.js"></script>
<script>mocha.run();</script>
<!-- @endif -->

<!-- @if tests=false -->
Expand Down
68 changes: 8 additions & 60 deletions app/models/mailbox.js
Original file line number Diff line number Diff line change
@@ -1,67 +1,15 @@
// Mailbox model
// =============

var Mailbox = Em.Object.extend();
var attr = DS.attr,
hasMany = DS.hasMany;

Mailbox.reopenClass({
find: function(id) {
if (id) {
return FIXTURES.findBy('id', id);
} else {
console.log(FIXTURES);
return FIXTURES;
}
}
var Mailbox = DS.Model.extend({
number: attr(),
name: attr(),
messages: hasMany('message')
});

export default Mailbox;
Mailbox.idField = 'number';

var FIXTURES = [
{
name: "Inbox",
id: "inbox",
messages: [
{
id: 1,
subject: "Welcome to Ember",
from: "[email protected]",
to: "[email protected]",
date: new Date(),
body: "Welcome to Ember. We hope you enjoy your stay"
}, {
id: 2,
subject: "Great Ember Resources",
from: "[email protected]",
to: "[email protected]",
date: new Date(),
body: "Have you seen embercasts.com? How about emberaddons.com?"
}
]
}, {
name: "Spam",
id: "spam",
messages: [
{
id: 3,
subject: "You have one the lottery!!!111ONEONE",
from: "[email protected]",
to: "[email protected]",
date: new Date(),
body: "You have ONE the lottery! You only have to send us a small amount of monies to claim your prize"
}
]
}, {
name: "Sent Mail",
id: "sent-mail",
messages: [
{
id: 4,
subject: "Should I use Ember",
from: "[email protected]",
to: "[email protected]",
date: new Date(),
body: "Ember looks pretty good, should I use it?"
}
]
}
];
export default Mailbox;
17 changes: 17 additions & 0 deletions app/models/message.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Message model
// =============

var attr = DS.attr;

var Message = DS.Model.extend({
number: attr(),
subject: attr(),
from: attr(),
to: attr(),
date: attr(),
body: attr()
});

Message.idField = 'number';

export default Message;
4 changes: 1 addition & 3 deletions app/routes/application.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// Application route
// ==================

import Mailbox from 'appkit/models/mailbox';

var ApplicationRoute = Em.Route.extend({
model: function() {
return Mailbox.find();
return this.store.find('mailbox');
}
});

Expand Down
2 changes: 0 additions & 2 deletions app/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<div class="url">URL: {{target.url}}</div>
<aside>

<ul>
<li><h2>Mailboxes</h2></li>
{{#each}}
Expand All @@ -15,7 +14,6 @@
{{/each}}
</ul>
</aside>

<section class="main">
{{outlet}}
</section>
3 changes: 3 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
"ember-data": "~1.0.0-beta.6",
"ember-resolver": "git://github.com/stefanpenner/ember-jj-abrams-resolver.git#master",
"ic-ajax": "~0.2",
"ember-mocha-adapter": "~0.1.2",
"ember-testing-httpRespond": "~0.1.1",
"mocha": "~1.17.0",
"chai": "~1.8.1",
"moment": "~2.4.0"
},
"resolutions": {
Expand Down
36 changes: 17 additions & 19 deletions tests/acceptance/component_test.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
var App;
// var App;

module('Acceptances - Component', {
setup: function(){
App = startApp();
},
teardown: function() {
Ember.run(App, 'destroy');
}
});

test('component output is rendered', function(){
expect(2);

visit('/component-test').then(function(){
var list = find('.pretty-color');
equal(list.length, 3);
equal(list.first().text(), 'Pretty Color: purple\n');
});
});
// module('Acceptances - Component', {
// setup: function(){
// App = startApp();
// },
// teardown: function() {
// Ember.run(App, 'destroy');
// }
// });
// test('component output is rendered', function(){
// expect(2);
// visit('/component-test').then(function(){
// var list = find('.pretty-color');
// equal(list.length, 3);
// equal(list.first().text(), 'Pretty Color: purple\n');
// });
// });

30 changes: 15 additions & 15 deletions tests/acceptance/helper_test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
var App;
// var App;

module("Acceptances - Helper", {
setup: function(){
App = startApp();
},
teardown: function() {
Ember.run(App, 'destroy');
}
});
// module("Acceptances - Helper", {
// setup: function(){
// App = startApp();
// },
// teardown: function() {
// Ember.run(App, 'destroy');
// }
// });

test("helper output is rendered", function(){
expect(1);
// test("helper output is rendered", function(){
// expect(1);

visit('/helper-test').then(function(){
ok(exists("h3:contains('My name is Ember.')"));
});
});
// visit('/helper-test').then(function(){
// ok(exists("h3:contains('My name is Ember.')"));
// });
// });

Loading

0 comments on commit 4fc5c77

Please sign in to comment.