forked from railsbridge/bridge_troll
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding link to 'Class Breakdown' page on Org Dashboard
Includes a somewhat inauspicious and strange start to the Class Breakdown page Adds backbone (via backbone-on-rails gem), jasmine, and a bunch of crazy .js files.
- Loading branch information
1 parent
31e3126
commit b95f7c8
Showing
23 changed files
with
289 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Bridgetroll = { | ||
Models: {}, | ||
Collections: {}, | ||
Views: {} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Bridgetroll.Collections.Student = Backbone.Collection.extend({ | ||
model: Bridgetroll.Models.Student | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Bridgetroll.Models.Student = Backbone.Model.extend({ | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Bridgetroll.Views.SectionOrganizer = Backbone.View.extend({ | ||
initialize: function (options) { | ||
this.subViews = []; | ||
this.students = options && options.students; | ||
|
||
this.students.each(function (student) { | ||
this.addStudent(student); | ||
}, this); | ||
}, | ||
|
||
render: function () { | ||
this.$el.empty(); | ||
|
||
_.each(this.subViews, function (view) { | ||
view.render(); | ||
this.$el.append(view.$el); | ||
}, this); | ||
}, | ||
|
||
addStudent: function (student) { | ||
var studentView = new Bridgetroll.Views.Student({model: student}); | ||
this.subViews.push(studentView); | ||
this.render(); | ||
}, | ||
|
||
addSection: function () { | ||
var section = new Bridgetroll.Views.Section(); | ||
this.subViews.push(section); | ||
this.render(); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Bridgetroll.Views.Section = Backbone.View.extend({ | ||
className: 'bridgetroll-section', | ||
|
||
render: function () { | ||
this.$el.empty(); | ||
this.$el.append('i am a section'); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Bridgetroll.Views.Student = Backbone.View.extend({ | ||
className: 'bridgetroll-student', | ||
|
||
render: function () { | ||
this.$el.empty(); | ||
this.$el.append(this.model.get('name')); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#section-organizer { | ||
height: 500px; | ||
border: 1px solid #ccc; | ||
border-radius: 10px; | ||
padding: 15px; | ||
} | ||
|
||
.bridgetroll-section { | ||
border: 1px solid green; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<%= content_for(:header_text, @event.title) %> | ||
|
||
<h2>Super Secret Organizer Section Organizing Tool</h2> | ||
|
||
<div id="section-organizer"></div> | ||
|
||
<script> | ||
$(document).ready(function () { | ||
var students = new Bridgetroll.Collections.Student( | ||
<%= @event.student_rsvps.map { |rsvp| { name: rsvp.user.full_name } }.to_json.html_safe %> | ||
); | ||
|
||
Bridgetroll.sectionOrganizer = new Bridgetroll.Views.SectionOrganizer({students: students}); | ||
Bridgetroll.sectionOrganizer.setElement($('#section-organizer')); | ||
Bridgetroll.sectionOrganizer.render(); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'spec_helper' | ||
|
||
describe "the section organizer tool" do | ||
before do | ||
@organizer = create(:user) | ||
@student = create(:user) | ||
|
||
@event = create(:event) | ||
@event.organizers << @organizer | ||
create(:student_rsvp, user: @student, event: @event) | ||
|
||
sign_in_as(@organizer) | ||
end | ||
|
||
it "should show the names of all students", js: true do | ||
visit organize_sections_event_path(@event) | ||
within '#section-organizer' do | ||
page.should have_content(@student.full_name) | ||
end | ||
end | ||
end |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
beforeEach(function() { | ||
this.addMatchers({ | ||
toBePlaying: function(expectedSong) { | ||
var player = this.actual; | ||
return player.currentlyPlayingSong === expectedSong | ||
&& player.isPlaying; | ||
} | ||
}) | ||
}); |
32 changes: 32 additions & 0 deletions
32
spec/javascripts/section_organizer/section_organizer_spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
describe("SectionOrganizer", function() { | ||
var sectionOrganizer; | ||
var students; | ||
beforeEach(function() { | ||
students = new Bridgetroll.Collections.Student([ | ||
{name: 'Lana Lang'}, | ||
{name: 'Sue Storm'}, | ||
{name: 'Ted Moesby'} | ||
]); | ||
sectionOrganizer = new Bridgetroll.Views.SectionOrganizer({students: students}); | ||
}); | ||
|
||
it("renders each of the students from the original collection", function () { | ||
sectionOrganizer.render(); | ||
expect(sectionOrganizer.$el.text()).toContain('Lana Lang'); | ||
expect(sectionOrganizer.$el.text()).toContain('Sue Storm'); | ||
expect(sectionOrganizer.$el.text()).toContain('Ted Moesby'); | ||
}); | ||
|
||
describe("#addSection", function () { | ||
it("adds a new section as a subview", function () { | ||
sectionOrganizer.render(); | ||
expect(sectionOrganizer.$('.bridgetroll-section').length).toEqual(0); | ||
|
||
sectionOrganizer.addSection(); | ||
expect(sectionOrganizer.$('.bridgetroll-section').length).toEqual(1); | ||
|
||
sectionOrganizer.addSection(); | ||
expect(sectionOrganizer.$('.bridgetroll-section').length).toEqual(2); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.