Permalink
Browse files

Adding footer, reworking tests a little, removing YARD dependency

  • Loading branch information...
1 parent 52e14cd commit e3358b40df3c4d8c461691c11d9b6d70833a20ca Harry Brundage committed Apr 13, 2010
View
7 .gems
@@ -1,5 +1,4 @@
-authlogic
-carmen
-simple_autocomplete
+authlogic --version 2.1.3
+carmen --version 0.1.1
+simple_autocomplete --version 0.3.1
rbacanable --version 0.2.2
-yard
File renamed without changes.
@@ -22,7 +22,7 @@
<div id="header">
<div class="container">
<div class="span-16">
- <h1>Accütron 9500</h1>
+ <h1>Name</h1>
<%= link_to "<img src=\"/images/logo.png\">", root_url %>
</div>
<div class="span-7 append-1 last right">
@@ -100,11 +100,10 @@
<!-- #content end -->
</div>
-
+ <div id="footer">
+ <p>Copyright &copy; 2010. By Harrison Brundage, Stéphane Lesieur, Nicholas Sabatino, Shen Chen Xu, and Qi Zhang. All rights reserved.</p>
+ </div>
<!-- #container end -->
</div>
-
- <div id="footer" class="span-22 push-1 last"></div>
-
</body>
</html>
View
@@ -1,11 +1,19 @@
-require 'yard'
# Delete the old rails doc:app task that used RDOC
Rake.application.instance_variable_get('@tasks').delete('doc:app')
-#Add the new Rake YARD task, name it :app to preserve the heirarchy.
-namespace :doc do
-YARD::Rake::YardocTask.new(:app) do |t|
- t.files = ['app/**/*.rb'] # optional
- t.options = ['--output-dir=doc/app', '--private'] # optional
-end
+begin
+ require 'yard'
+ #Add the new Rake YARD task, name it :app to preserve the heirarchy.
+ namespace :doc do
+ YARD::Rake::YardocTask.new(:app) do |t|
+ t.files = ['app/**/*.rb'] # optional
+ t.options = ['--output-dir=doc/app', '--private'] # optional
+ end
+ end
+ rescue LoadError
+ namespace :doc do
+ task :app do
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
+ end
+ end
end
@@ -18,12 +18,6 @@ body {
}
#header {
- /* background-color: #FF7E00;
- -moz-border-radius-bottomleft: 15px;
- -webkit-border-bottom-left-radius: 15px;
- -moz-border-radius-bottomright: 15px;
- -webkit-border-bottom-right-radius: 15px;
- */
border-top: 4px solid #e71818;
margin-bottom: 10px;
width: 100%;
@@ -47,6 +41,10 @@ ul#menu li {
ul#menu ul {
padding: 2px 0px 0px 15px;
}
+#footer {
+ color: #999;
+ text-align: center;
+}
/* Reset Blueprint's consecutive paragraph indent since we aren't doing blocks of text */
p + p {
text-indent: 0px;
@@ -1,5 +1,5 @@
Factory.define :hour_report do |e|
- e.hours rand(5) + 1
+ e.hours 10
e.sequence(:name) {|n| "Hour Report ##{n}" }
e.description "Something that cost money."
e.association :user
@@ -0,0 +1,3 @@
+Factory.define :user_session do |u|
+ u.association :user, :factory => :admin
+end
@@ -1,52 +1,58 @@
require 'test_helper'
class ExpensesControllerTest < ActionController::TestCase
+ setup :activate_authlogic
context "Without a logged in user" do
- should_not_allow_any_actions
+ should_not_allow_any_actions_if_not_logged_in
end
context "With a logged in administrator user" do
+ setup do
+ @user_session = UserSession.new Factory.create(:admin)
+ @user = @user_session.user
+ end
- end
- test "should get index" do
- get :index
- assert_response :success
- assert_not_nil assigns(:expenses)
- end
-
- test "should get new" do
- get :new
- assert_response :success
- end
+ should "get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:expenses)
+ end
- test "should create expense" do
- assert_difference('Expense.count') do
- post :create, :expense => { }
+ should "get new" do
+ get :new
+ assert_response :success
end
- assert_redirected_to expense_path(assigns(:expense))
- end
+ should "create expense" do
+ assert_difference('Expense.count') do
+ post :create, :expense => { }
+ end
- test "should show expense" do
- get :show, :id => expenses(:one).to_param
- assert_response :success
- end
+ assert_redirected_to expense_path(assigns(:expense))
+ end
- test "should get edit" do
- get :edit, :id => expenses(:one).to_param
- assert_response :success
- end
+ should "show expense" do
+ get :show, :id => expenses(:one).to_param
+ assert_response :success
+ end
- test "should update expense" do
- put :update, :id => expenses(:one).to_param, :expense => { }
- assert_redirected_to expense_path(assigns(:expense))
- end
+ should "get edit" do
+ get :edit, :id => expenses(:one).to_param
+ assert_response :success
+ end
- test "should destroy expense" do
- assert_difference('Expense.count', -1) do
- delete :destroy, :id => expenses(:one).to_param
+ should "update expense" do
+ put :update, :id => expenses(:one).to_param, :expense => { }
+ assert_redirected_to expense_path(assigns(:expense))
end
- assert_redirected_to expenses_path
+ should "destroy expense" do
+ assert_difference('Expense.count', -1) do
+ delete :destroy, :id => expenses(:one).to_param
+ end
+
+ assert_redirected_to expenses_path
+ end
end
+
end
View
@@ -21,7 +21,7 @@ def can_#{can}?(resource)
end
require 'test_help'
require "authlogic/test_case"
-#require File.expand_path(File.dirname(__FILE__) + "/../lib/colored_tests")
+
class ActiveSupport::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
@@ -56,157 +56,35 @@ class ActiveSupport::TestCase
fixtures :all
# Add more helper methods to be used by all tests here...
-
- def self.should_allow_admin_crud
- should "be updatable by admin" do
- assert @admin.can_update?(subject)
- end
- end
-
- def self.should_allow_everyone_to_view
- should "be viewable by everyone" do
- @all_users.each do |user|
- assert user.can_view?(subject)
+ def self.should_not_allow_any_actions_if_not_logged_in
+ context "without a logged in user, the controller" do
+ setup do
+ assert @current_user == nil
end
- end
- end
-
- def self.should_only_be_destructable_by_admins
- should "not be destructable by anyone other than admins" do
- @not_admins.each do |user|
- assert ! user.can_destroy?(subject)
+
+ should "not permit access to the index action" do
+ get :index
+ assert_redirected_to(new_user_session_path)
end
- end
- end
-
- def self.should_only_be_editable_by_associated_project_managers
- should "be editable by a manager who manages an associated project" do
- assert @owning_manager.can_update?(subject)
- end
- should "not be editable by managers who aren't managing the associated project" do
- assert ! @extra_manager.can_update?(subject)
- end
- end
-
- def self.should_be_editable_by_all_managers
- should "be editable by all managers" do
- [@owning_manager, @extra_manager].each do |user|
- assert user.can_update?(subject)
+ should "not permit access to the new action" do
+ get :new
+ assert_redirected_to(new_user_session_path)
end
- end
- end
-
- def self.should_not_be_editable_by_employees
- should "not be editable by employees" do
- assert ! @user.can_update?(subject)
- end
- end
-
- def self.should_be_approvable_by_project_manager
- should "be approvable and rejectable by project manager" do
- assert @owning_manager.can_approve?(subject)
- assert @owning_manager.can_reject?(subject)
- end
- should "not be approvable by managers who aren't managing the associated project" do
- assert ! @extra_manager.can_approve?(subject)
- assert ! @extra_manager.can_reject?(subject)
- end
- end
-
- def self.should_only_be_editable_by_creator_user
- should "be updatable by user who created it" do
- assert @owning_user.can_update?(subject)
- end
- should "not be updatable by a user who did not create it" do
- assert ! @extra_user.can_update?(subject)
- end
- end
-
- def self.should_only_allow_admins_to_destroy
- should "not be destructable by anyone except an administrator" do
- @not_admins.each do |user|
- assert ! user.can_destroy?(subject)
- end
- assert @admin.can_destroy?(subject)
- end
- end
-
- def self.should_not_allow_any_actions
- should "not permit access to the index action" do
- get :index
- assert_redirected_to(new_user_session_path)
- end
- should "not permit access to the new action" do
- get :new
- assert_redirected_to(new_user_session_path)
- end
- should "not permit access to the edit action" do
- get :edit, :id => Factory(:expense).id
- assert_redirected_to(new_user_session_path)
- end
+ should "not permit access to the edit action" do
+ get :edit, :id => Factory(:expense).id
+ assert_redirected_to(new_user_session_path)
+ end
- should "not permit access to the update action" do
- put :update, :id => Factory(:expense).id
- assert_redirected_to(new_user_session_path)
- end
- should "not permit access to the destroy action" do
- delete :destroy, :id => Factory(:expense).id
- assert_redirected_to(new_user_session_path)
- end
- end
-
- def self.should_allow_only_admin_crud
- should_allow_admin_crud
- Canable.actions.each do |can, able|
- method_name = "#{able}_by?".intern
- should "not allow non-admins to #{can}" do
- assert subject.respond_to?(method_name), "#{subject} doesn't respond to #{method_name}"
- @not_admins.each do |user|
- assert ! subject.send(method_name, user), "User #{user} of type #{user.canable_included_role} can #{can}."
- end
+ should "not permit access to the update action" do
+ put :update, :id => Factory(:expense).id
+ assert_redirected_to(new_user_session_path)
end
- end
- end
-
- def self.project_cost_should_allow_associated_employees_to_create
- should "not be creatable by users if no task is specified" do
- @not_admins.each do |user|
- assert ! user.can_create?(Expense.new)
+ should "not permit access to the destroy action" do
+ delete :destroy, :id => Factory(:expense).id
+ assert_redirected_to(new_user_session_path)
end
end
- should "be creatable by users associated with the project" do
- assert @associated_user.can_create?(Expense.new(:task => subject.task))
- end
- should "not be creatable by users who aren't associated with the project" do
- assert ! @extra_user.can_create?(Expense.new(:task => subject.task))
- end
end
- def self.project_cost_should_be_destroyable_by_creator_user_if_not_approved
- should "not be destructable by non owning employees" do
- assert ! @extra_user.can_destroy?(subject)
- end
- should "be destructable by the owning user if the expense state is Pending" do
- subject.state = ProjectCost::Pending
- assert @owning_user.can_destroy?(subject)
- end
- should "be destructable by the owning user if the expense state is Rejected" do
- subject.state = ProjectCost::Rejected
- assert @owning_user.can_destroy?(subject)
- end
- should "not be destructable by the owning user if the expense state is Approved" do
- subject.state = ProjectCost::Approved
- assert ! @owning_user.can_destroy?(subject)
- end
- end
-
- def self.should_act_as_project_cost
- should_only_be_editable_by_creator_user
- should_only_be_editable_by_associated_project_managers
- should_be_approvable_by_project_manager
- should_only_be_editable_by_creator_user
- project_cost_should_allow_associated_employees_to_create
- project_cost_should_be_destroyable_by_creator_user_if_not_approved
- end
end
Oops, something went wrong.

0 comments on commit e3358b4

Please sign in to comment.