Skip to content

Commit

Permalink
Basic styling, better tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chicks committed Feb 27, 2011
1 parent 567bd20 commit e81a4f7
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 7 deletions.
9 changes: 9 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
module ApplicationHelper
def module_menu
html = ""
["Accounts", "Opportunities", "Users"].each do |m|
html << content_tag(:li, :class => :module) do
link_to(m, module_path(m.downcase))
end
end
html
end
end
11 changes: 8 additions & 3 deletions app/helpers/sugar_beans_helper.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
module SugarBeansHelper
def display_as_list(beans)
html = "<div class='beans'>"
html = "<div class='container'>"
html << " <div class='container_header'>#{@module.capitalize}</div>"
html << " <table class='beans'>"
beans.each do |bean|
html << content_tag(:p, :id => bean.id) do
link_to(bean.name, sugar_bean_path(@module, bean.id))
html << content_tag(:tr, :id => bean.id) do
content_tag(:td) do
link_to(bean.name, sugar_bean_path(@module, bean.id))
end
end
end
html << " </table>"
html << "</div>"
end

Expand Down
6 changes: 6 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
</head>
<body>

<div class="header">
<ul class="modules">
<%= raw module_menu %>
</ul>
</div>

<%= yield %>

</body>
Expand Down
2 changes: 0 additions & 2 deletions app/views/sugar_beans/list.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
<h1><%= @module.capitalize %></h1>

<%= raw display_as_list(@beans) %>
6 changes: 4 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
SugarOnRailsBasic::Application.routes.draw do
#get "users#show"
root :to => "accounts#list"

match ':module' => 'sugar_beans#list'
match ':module' => 'sugar_beans#list', :as => "module"
match ':module/:id' => 'sugar_beans#show', :as => "sugar_bean"

root :to => "sugar_beans#list", :module => "accounts"

# The priority is based upon order of creation:
# first created -> highest priority.

Expand Down
Binary file added public/images/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/container_header.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/menu_row.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions public/stylesheets/application.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
body {
color: #444;
background-color: #dedede;
background-image:url('/images/background.png');
background-repeat:no-repeat;
margin: 0px;
font-family: Arial, Verdana, Helvetica, sans-serif;
}

a:link a:visited a:hover a:active {
text-decoration: none;
}

h1, h2, h3 {
color: #999;
}

.modules {
background-color: transparent;
background-image: url('/images/menu_row.png');
background-repeat: repeat-x;
color: #444;
list-style: none;
height: 45px;
}

.module {
display: inline-block;
line-height: 26px;
margin-top: 5px;
height: 26px;
color: #666;
font-size: 15px;
padding: 4px 15px 4px 15px;
text-shadow: 1px 1px #EFEFEF;
font-weight: bold;
border-left: 1px solid #CCC;
}

.module a {
color: #666;
font-weight: bold;
}

.container {
border: 1px solid #98C6EA;
margin: 10px;
box-shadow: #CCC 0px 0px 10px;
-moz-box-shadow: #CCC 0px 0px 10px;
-webkit-box-shadow: #CCC 0px 0px 10px;
-moz-border-radius: 6px;
border-radius: 6px;
-webkit-border-radius: 6px;
border-top-left-radius: 6px 6px;
border-top-right-radius: 6px 6px;
border-bottom-right-radius: 6px 6px;
border-bottom-left-radius: 6px 6px;
}

.container_header {
font-size: 18px;
line-height: 22px;
height: 26px;
padding: 2px 0px 2px 10px;
background: url(/images/container_header.png) repeat-x top center;
background-color: #CCC;
border-top-left-radius: 6px 6px;
border-top-right-radius: 6px 6px;
border-radius-bottomleft: 0px;
border-radius-bottomright: 0px;
-moz-border-radius-bottomleft: 0px;
-moz-border-radius-bottomright: 0px;
-webkit-border-bottom-right-radius: 0px;
-webkit-border-bottom-left-radius: 0px;
text-shadow: 0px 1px white;
border-bottom-right-radius: 0px 0px;
border-bottom-left-radius: 0px 0px;
}

.beans {
padding: 2px 0px 2px 10px;
}
8 changes: 8 additions & 0 deletions test/functional/sugar_beans_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require 'test_helper'

class SugarBeansControllerTest < ActionController::TestCase
# TODO: Figure out how to test the root route

test "should get accounts#list" do
get(:list, {:module => "accounts"})
assert_response :success
Expand All @@ -10,4 +12,10 @@ class SugarBeansControllerTest < ActionController::TestCase
get(:show, {:module => "users", :id => "1"})
assert_response :success
end

test "should display available modules" do
get(:list, {:module => "kittens"})
assert_response :success
end

end

0 comments on commit e81a4f7

Please sign in to comment.