Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started adding notifications and import jobs
- Loading branch information
Jeremy Stephens
committed
Aug 9, 2011
1 parent
2e31b8c
commit fc05223
Showing
19 changed files
with
216 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Sequel.migration do | ||
up do | ||
create_table(:notifications) do | ||
primary_key :id | ||
String :message | ||
String :url | ||
TrueClass :seen | ||
Time :created_at | ||
Time :updated_at | ||
end | ||
end | ||
down do | ||
drop_table(:notifications) | ||
end | ||
end |
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,14 @@ | ||
module Coupler | ||
module Extensions | ||
module Notifications | ||
include Models | ||
|
||
def self.registered(app) | ||
app.get "/notifications" do | ||
@notifications = Notification.order(:created_at).all | ||
erb :"notifications/index" | ||
end | ||
end | ||
end | ||
end | ||
end |
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,7 @@ | ||
module Coupler | ||
module Models | ||
class Notification < Sequel::Model | ||
include CommonModel | ||
end | ||
end | ||
end |
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,20 @@ | ||
require 'helper' | ||
|
||
module CouplerFunctionalTests | ||
class TestNotifications < Coupler::Test::FunctionalTest | ||
|
||
test "empty index" do | ||
visit "/notifications" | ||
assert_equal 200, page.status_code | ||
end | ||
|
||
test "index" do | ||
n1 = Notification.create(:message => "Test!") | ||
n2 = Notification.create(:message => "Another Test!", :url => "/projects") | ||
n3 = Notification.create(:message => "Foo", :seen => true) | ||
n4 = Notification.create(:message => "Bar", :url => "/connections", :seen => true) | ||
visit "/notifications" | ||
assert_equal 200, page.status_code | ||
end | ||
end | ||
end |
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 @@ | ||
require 'helper' | ||
|
||
module TestModels | ||
class TestNotification < Coupler::Test::UnitTest | ||
include Coupler::Models | ||
Coupler::Models::Notification # force load | ||
|
||
test "sequel model" do | ||
assert_equal ::Sequel::Model, Notification.superclass | ||
assert_equal :notifications, Notification.table_name | ||
end | ||
|
||
test "common model" do | ||
assert Notification.ancestors.include?(CommonModel) | ||
end | ||
end | ||
end |
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,16 @@ | ||
<%- @breadcrumbs = ["Notifications"] -%> | ||
<%- if @notifications.empty? -%> | ||
<p>There are currently no notifications.</p> | ||
<%- else -%> | ||
<ul class="notifications"> | ||
<%- @notifications.each do |notification| -%> | ||
<li class="notification"> | ||
<% if notification.url %> | ||
<a href="<%= notification.url %>"><%= notification.message %></a> | ||
<% else %> | ||
<%= notification.message %> | ||
<% end %> | ||
</li> | ||
<%- end -%> | ||
</ul> | ||
<%- end -%> |
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