Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: eldewall/backbone_contacts
base: 8e40938496
...
head fork: eldewall/backbone_contacts
compare: 3bdbc097a7
  • 1 commit
  • 11 files changed
  • 0 commit comments
  • 1 contributor
Commits on Aug 17, 2012
Erik Eldewall added lots of shit 3bdbc09
20 Gemfile.lock
View
@@ -35,7 +35,7 @@ GEM
jquery-rails
railties (>= 3.1)
builder (3.0.0)
- childprocess (0.3.4)
+ childprocess (0.3.5)
ffi (~> 1.0, >= 1.0.6)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
@@ -54,24 +54,24 @@ GEM
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
- ffi (1.1.4)
- guard (1.3.0)
+ ffi (1.1.5)
+ guard (1.3.2)
listen (>= 0.4.2)
thor (>= 0.14.6)
- guard-jasmine (1.6.1)
+ guard-jasmine (1.7.0)
childprocess
guard (>= 1.1.0)
multi_json
thor
- haml (3.1.6)
+ haml (3.1.7)
hike (1.2.1)
i18n (0.6.0)
jasminerice (0.0.9)
coffee-rails
haml
journey (1.0.4)
- jquery-rails (2.0.2)
- railties (>= 3.2.0, < 5.0)
+ jquery-rails (2.1.0)
+ railties (>= 3.1.0, < 5.0)
thor (~> 0.14)
json (1.7.4)
kgio (2.7.4)
@@ -124,13 +124,13 @@ GEM
rspec-core (2.11.1)
rspec-expectations (2.11.2)
diff-lcs (~> 1.1.3)
- rspec-mocks (2.11.1)
+ rspec-mocks (2.11.2)
rspec-rails (2.11.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.11.0)
- sass (3.1.20)
+ sass (3.2.1)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
@@ -140,7 +140,7 @@ GEM
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.6)
- thor (0.15.4)
+ thor (0.16.0)
tilt (1.3.3)
treetop (1.4.10)
polyglot
2  app/assets/javascripts/collections/contacts.js.coffee
View
@@ -1,5 +1,5 @@
class ContactsApp.Collections.Contacts extends Backbone.Collection
- Model: ContactsApp.Models.Contact
+ model: ContactsApp.Models.Contact
url: '/contacts'
1  app/assets/javascripts/models/contact.js.coffee
View
@@ -11,7 +11,6 @@ class ContactsApp.Models.Contact extends Backbone.Model
@on('change:first_name', @setName, this)
@on('change:last_name', @setName, this)
-
setName: ->
fullname = @get('first_name') + ' ' + @get('last_name')
@set("name", fullname, silent: true)
5 app/assets/javascripts/views/contact_view.js.coffee
View
@@ -10,10 +10,9 @@ class ContactsApp.Views.ContactView extends Backbone.View
'click' : 'edit'
initialize: ->
- @render()
-
+
edit: ->
- console.log "hej"
+ new ContactsApp.Views.ContactEditView(model: @model)
render: ->
$(@el).html(@template(@model.toJSON()))
4 app/assets/javascripts/views/contacts_view.js.coffee
View
@@ -14,9 +14,9 @@ class ContactsApp.Views.ContactsView extends Backbone.View
$(@el).html(@template)
renderContacts: =>
- @collection.each(@appendView)
+ @collection.each(@appendView)
appendView: (model) =>
view = new ContactsApp.Views.ContactView(model: model)
- @subviews.push view
+ @subviews.push(view)
$('.contacts', @el).append(view.render().el)
2  app/assets/templates/contacts/contact.jst.eco
View
@@ -1,5 +1,5 @@
<ul>
- <li class="name"><%= @first_name %></li>
+ <li class="name"><%= @name %></li>
<li class="email"><%= @email %></li>
<li class="phone"><%= @phone %></li>
</ul>
1  app/controllers/contacts_controller.rb
View
@@ -3,4 +3,5 @@ class ContactsController < ApplicationController
def index
render json: Contact.all
end
+
end
2  spec/javascripts/collections/contacts_spec.js.coffee
View
@@ -5,3 +5,5 @@ describe 'collections/Contacts', ->
it 'can be instantiated', ->
collection = new ContactsApp.Collections.Contacts()
expect(collection).not.toBeNull()
+
+
17 spec/javascripts/models/contact_spec.js.coffee
View
@@ -19,6 +19,14 @@ describe 'models/Contact', ->
model.set(first_name: "A", last_name: "B")
expect(model.get('name')).toEqual("A B")
+ it 'should set name on new instance', ->
+ model = new ContactsApp.Models.Contact(
+ first_name: "Erik",
+ last_name: "Eldewall"
+ )
+
+ expect(model.get('name')).toEqual("Erik Eldewall")
+
describe 'instance default values', ->
beforeEach ->
@contact = new ContactsApp.Models.Contact()
@@ -34,3 +42,12 @@ describe 'models/Contact', ->
it 'has default value for phone', ->
expect(@contact.get('phone')).toEqual('')
+
+ describe "JSON", ->
+ beforeEach ->
+ @contact = new ContactsApp.Models.Contact()
+
+ it "should have name defined as json", ->
+ json = @contact.toJSON()
+ expect(json.name).toBeDefined()
+
2  spec/javascripts/routers/contacts_router_spec.js.coffee
View
@@ -41,7 +41,7 @@ describe "routers/Contacts", ->
afterEach ->
Backbone.history.stop()
-
+
describe "index", ->
it "should have a index action", ->
expect(@router.index).toBeDefined()
6 spec/javascripts/views/contact_view_spec.js.coffee
View
@@ -21,14 +21,18 @@ describe "ContactView", ->
describe 'behaviour', ->
it 'should call edit on click', ->
view = new ContactsApp.Views.ContactView(model: @model)
- spy = spyOn(view, "edit")
+ spy = spyOn(view, "edit").andCallThrough()
view.delegateEvents()
$(view.el).click()
expect(spy).toHaveBeenCalled()
describe 'edit', ->
it "should create a edit view passing model", ->
+ view = new ContactsApp.Views.ContactView(model: @model)
+ spy = spyOn(ContactsApp.Views, "ContactEditView")
+ view.edit()
+ expect(spy).toHaveBeenCalledWith( { @model } )
describe 'element', ->
beforeEach ->

No commit comments for this range

Something went wrong with that request. Please try again.