get project integrations and login controller tests running

This commit is contained in:
Reinier Balt 2012-04-20 14:38:00 +02:00
parent 59a4d5ede0
commit 96db48dd86
36 changed files with 179 additions and 223 deletions

View file

@ -12,6 +12,7 @@ gem "mysql2"
gem "highline", "~>1.5.0" gem "highline", "~>1.5.0"
gem "RedCloth" gem "RedCloth"
gem "formatize"
gem "sanitize", "~>1.2.1" gem "sanitize", "~>1.2.1"
gem "will_paginate" gem "will_paginate"
gem "acts_as_list", "~>0.1.4" gem "acts_as_list", "~>0.1.4"

View file

@ -33,6 +33,7 @@ GEM
acts_as_list (0.1.5) acts_as_list (0.1.5)
arel (3.0.2) arel (3.0.2)
bcrypt-ruby (3.0.1) bcrypt-ruby (3.0.1)
bluecloth (2.2.0)
builder (3.0.0) builder (3.0.0)
coffee-rails (3.2.2) coffee-rails (3.2.2)
coffee-script (>= 2.2.0) coffee-script (>= 2.2.0)
@ -45,6 +46,10 @@ GEM
erubis (2.7.0) erubis (2.7.0)
execjs (1.3.0) execjs (1.3.0)
multi_json (~> 1.0) multi_json (~> 1.0)
formatize (1.1.0)
RedCloth (~> 4.2)
actionpack (~> 3.0)
bluecloth (~> 2.2)
gem_plugin (0.2.3) gem_plugin (0.2.3)
highline (1.5.2) highline (1.5.2)
hike (1.2.1) hike (1.2.1)
@ -131,6 +136,7 @@ DEPENDENCIES
acts_as_list (~> 0.1.4) acts_as_list (~> 0.1.4)
bcrypt-ruby (~> 3.0.0) bcrypt-ruby (~> 3.0.0)
coffee-rails (~> 3.2.1) coffee-rails (~> 3.2.1)
formatize
highline (~> 1.5.0) highline (~> 1.5.0)
htmlentities (~> 4.3.0) htmlentities (~> 4.3.0)
jquery-rails jquery-rails

View file

@ -9,7 +9,6 @@ class ApplicationController < ActionController::Base
protect_from_forgery protect_from_forgery
helper :application
include LoginSystem include LoginSystem
helper_method :current_user, :prefs, :format_date, :markdown helper_method :current_user, :prefs, :format_date, :markdown
@ -143,14 +142,6 @@ class ApplicationController < ActionController::Base
return json_elems return json_elems
end end
# Uses RedCloth to transform text using either Textile or Markdown Need to
# require redcloth above RedCloth 3.0 or greater is needed to use Markdown,
# otherwise it only handles Textile
#
def markdown(text)
RedCloth.new(text).to_html
end
# Here's the concept behind this "mobile content negotiation" hack: In # Here's the concept behind this "mobile content negotiation" hack: In
# addition to the main, AJAXy Web UI, Tracks has a lightweight low-feature # addition to the main, AJAXy Web UI, Tracks has a lightweight low-feature
# 'mobile' version designed to be suitablef or use from a phone or PDA. It # 'mobile' version designed to be suitablef or use from a phone or PDA. It
@ -223,7 +214,7 @@ class ApplicationController < ActionController::Base
def redirect_back_or_home def redirect_back_or_home
respond_to do |format| respond_to do |format|
format.html { redirect_back_or_default home_url } format.html { redirect_back_or_default root_url }
format.m { redirect_back_or_default mobile_url } format.m { redirect_back_or_default mobile_url }
end end
end end

View file

@ -53,7 +53,7 @@ class IntegrationsController < ApplicationController
message = Mail.new(params[:message]) message = Mail.new(params[:message])
# find user # find user
user = User.where("preferences.sms_email = ?", message.from).includes(:preferences).first user = User.where("preferences.sms_email = ?", message.from).includes(:preference).first
if user.nil? if user.nil?
render :text => "No user found", :status => 404 render :text => "No user found", :status => 404
return false return false

View file

@ -27,15 +27,13 @@ class LoginController < ApplicationController
@username = session[:cas_user] @username = session[:cas_user]
@login_url = CASClient::Frameworks::Rails::Filter.login_url(self) @login_url = CASClient::Frameworks::Rails::Filter.login_url(self)
end end
if openid_enabled? && using_open_id? if cas_enabled? && session[:cas_user]
login_openid
elsif cas_enabled? && session[:cas_user]
login_cas login_cas
else else
@page_title = "TRACKS::Login" @page_title = "TRACKS::Login"
cookies[:preferred_auth] = prefered_auth? unless cookies[:preferred_auth] cookies[:preferred_auth] = prefered_auth? unless cookies[:preferred_auth]
case request.method case request.method
when :post when 'POST'
if @user = User.authenticate(params['user_login'], params['user_password']) if @user = User.authenticate(params['user_login'], params['user_password'])
session['user_id'] = @user.id session['user_id'] = @user.id
# If checkbox on login page checked, we don't expire the session after 1 hour # If checkbox on login page checked, we don't expire the session after 1 hour
@ -54,7 +52,7 @@ class LoginController < ApplicationController
@login = params['user_login'] @login = params['user_login']
notify :warning, t('login.unsuccessful') notify :warning, t('login.unsuccessful')
end end
when :get when 'GET'
if User.no_users_yet? if User.no_users_yet?
redirect_to signup_path redirect_to signup_path
return return

View file

@ -9,7 +9,6 @@ class ProjectsController < ApplicationController
def index def index
@source_view = params['_source_view'] || 'project_list' @source_view = params['_source_view'] || 'project_list'
@new_project = current_user.projects.build
if params[:projects_and_actions] if params[:projects_and_actions]
projects_and_actions projects_and_actions
else else
@ -19,15 +18,22 @@ class ProjectsController < ApplicationController
if params[:only_active_with_no_next_actions] if params[:only_active_with_no_next_actions]
@projects = current_user.projects.active.select { |p| count_undone_todos(p) == 0 } @projects = current_user.projects.active.select { |p| count_undone_todos(p) == 0 }
else else
@projects = current_user.projects @projects = current_user.projects.all
end end
@new_project = current_user.projects.build
respond_to do |format| respond_to do |format|
format.html &render_projects_html format.html &render_projects_html
format.m &render_projects_mobile format.m &render_projects_mobile
format.xml { render :xml => @projects.to_xml( :except => :user_id ) } format.xml { render :xml => @projects.to_xml( :except => :user_id ) }
format.rss &render_rss_feed format.rss do
format.atom &render_atom_feed @feed_title = I18n.t('models.project.feed_title')
format.text &render_text_feed @feed_description = I18n.t('models.project.feed_description', :username => current_user.display_name)
end
format.atom do
@feed_title = I18n.t('models.project.feed_title')
@feed_description = I18n.t('models.project.feed_description', :username => current_user.display_name)
end
format.text
format.autocomplete &render_autocomplete format.autocomplete &render_autocomplete
end end
end end
@ -144,16 +150,9 @@ class ProjectsController < ApplicationController
render_failure "Expected post format is valid xml like so: <request><project><name>project name</name></project></request>." render_failure "Expected post format is valid xml like so: <request><project><name>project name</name></project></request>."
return return
end end
@project = current_user.projects.build(params['project'])
@project = current_user.projects.build
params_are_invalid = true
if (params['project'] || (params['request'] && params['request']['project']))
@project.attributes = params['project'] || params['request']['project']
params_are_invalid = false
end
@go_to_project = params['go_to_project'] @go_to_project = params['go_to_project']
@saved = @project.save @saved = @project.save
@project_not_done_counts = { @project.id => 0 } @project_not_done_counts = { @project.id => 0 }
@active_projects_count = current_user.projects.active.count @active_projects_count = current_user.projects.active.count
@contexts = current_user.contexts @contexts = current_user.contexts
@ -161,9 +160,7 @@ class ProjectsController < ApplicationController
respond_to do |format| respond_to do |format|
format.js { @down_count = current_user.projects.size } format.js { @down_count = current_user.projects.size }
format.xml do format.xml do
if @project.new_record? && params_are_invalid if @project.new_record?
render_failure "Expected post format is valid xml like so: <request><project><name>project name</name></project></request>."
elsif @project.new_record?
render_failure @project.errors.full_messages.join(', ') render_failure @project.errors.full_messages.join(', ')
else else
head :created, :location => project_url(@project), :text => @project.id head :created, :location => project_url(@project), :text => @project.id
@ -350,33 +347,6 @@ class ProjectsController < ApplicationController
render :action => 'project_mobile' render :action => 'project_mobile'
end end
end end
def render_rss_feed
lambda do
render_rss_feed_for @projects, :feed => feed_options,
:title => :name,
:item => { :description => lambda { |p| @template.summary(p) } }
end
end
def render_atom_feed
lambda do
render_atom_feed_for @projects, :feed => feed_options,
:item => { :description => lambda { |p| @template.summary(p) },
:title => :name,
:author => lambda { |p| nil } }
end
end
def feed_options
Project.feed_options(current_user)
end
def render_text_feed
lambda do
render :action => 'index', :layout => false, :content_type => Mime::TEXT
end
end
def render_autocomplete def render_autocomplete
lambda do lambda do

View file

@ -75,9 +75,9 @@ module ProjectsHelper
project_description = '' project_description = ''
project_description += Tracks::Utils.render_text( project.description ) unless project.description.blank? project_description += Tracks::Utils.render_text( project.description ) unless project.description.blank?
project_description += content_tag(:p, project_description += content_tag(:p,
"#{count_undone_todos_phrase(p)}. " + t('projects.project_state', :state => project.state) "#{count_undone_todos_phrase(p)}. #{t('projects.project_state', :state => project.state)}".html_safe
) )
project_description raw project_description
end end
def needsreview_class(item) def needsreview_class(item)

View file

@ -47,13 +47,6 @@ class Project < ActiveRecord::Base
NullProject.new NullProject.new
end end
def self.feed_options(user)
{
:title => I18n.t('models.project.feed_title'),
:description => I18n.t('models.project.feed_description', :username => user.display_name)
}
end
def hide_todos def hide_todos
todos.each do |t| todos.each do |t|
unless t.completed? || t.deferred? unless t.completed? || t.deferred?

View file

@ -6,13 +6,13 @@ set myUsername to "<%= current_user.login %>"
set myToken to "<%= current_user.token %>" set myToken to "<%= current_user.token %>"
set myContextID to <%= context.id %> (* <%= context.name %> *) set myContextID to <%= context.id %> (* <%= context.name %> *)
-- Display dialog to enter your description -- Display dialog to enter your description
display dialog "<%= t('integrations.applescript_next_action_prompt') %>" default answer "" display dialog "<%= t('integrations.applescript_next_action_prompt') %>" default answer ""
set myDesc to text returned of the result set myDesc to text returned of the result
-- Now send all that info to Tracks -- Now send all that info to Tracks
-- Edit the URL of your Tracks installation if necessary" -- Edit the URL of your Tracks installation if necessary"
tell application "<%= home_url %>backend/api" tell application "<%= root_url %>backend/api"
set returnValue to call xmlrpc {method name:"NewTodo", parameters:{myUsername, myToken, myContextID, myDesc}} set returnValue to call xmlrpc {method name:"NewTodo", parameters:{myUsername, myToken, myContextID, myDesc}}
end tell end tell

View file

@ -1,10 +1,10 @@
(* (*
Script to grab the sender and subject of the selected Script to grab the sender and subject of the selected
Mail message(s), and create new next action(s) with description Mail message(s), and create new next action(s) with description
"Email [sender] about [subject]" "Email [sender] about [subject]"
If you have Growl, it pops a notification up with the id of If you have Growl, it pops a notification up with the id of
the newly created action. the newly created action.
*) *)
(* Edit appropriately for your setup *) (* Edit appropriately for your setup *)
@ -50,25 +50,25 @@ on importMessage(theMessage)
-- Now send all that info to Tracks -- Now send all that info to Tracks
-- Edit the URL of your Tracks installation if necessary" -- Edit the URL of your Tracks installation if necessary"
tell application "<%= home_url %>backend/api" tell application "<%= root_url %>backend/api"
set returnValue to call xmlrpc {method name:"NewTodo", parameters:{myUsername, myToken, myContextID, myDesc, myNote}} set returnValue to call xmlrpc {method name:"NewTodo", parameters:{myUsername, myToken, myContextID, myDesc, myNote}}
end tell end tell
(* Growl support - comment out or delete this section if (* Growl support - comment out or delete this section if
you don't have Growl *) you don't have Growl *)
tell application "GrowlHelperApp" tell application "GrowlHelperApp"
set the allNotificationsList to ¬ set the allNotificationsList to ¬
{"Tracks Notification"} {"Tracks Notification"}
-- Make a list of the notifications -- Make a list of the notifications
-- that will be enabled by default. -- that will be enabled by default.
-- Those not enabled by default can be enabled later -- Those not enabled by default can be enabled later
-- in the 'Applications' tab of the growl prefpane. -- in the 'Applications' tab of the growl prefpane.
set the enabledNotificationsList to ¬ set the enabledNotificationsList to ¬
{"Tracks Notification"} {"Tracks Notification"}
-- Register our script with growl. -- Register our script with growl.
-- You can optionally (as here) set a default icon -- You can optionally (as here) set a default icon
-- for this script's notifications. -- for this script's notifications.
register as application ¬ register as application ¬
"Tracks Applescript" all notifications allNotificationsList ¬ "Tracks Applescript" all notifications allNotificationsList ¬

View file

@ -5,7 +5,7 @@ using terms from application "Quicksilver"
set myToken to "<%= current_user.token %>" set myToken to "<%= current_user.token %>"
set myContextID to <%= context.id %> (* <%= context.name %> *) set myContextID to <%= context.id %> (* <%= context.name %> *)
tell application "<%= home_url %>backend/api" tell application "<%= root_url %>backend/api"
set returnValue to call xmlrpc {method name:"NewTodo", parameters:{myUsername, myToken, myContextID, ThisClipping}} set returnValue to call xmlrpc {method name:"NewTodo", parameters:{myUsername, myToken, myContextID, ThisClipping}}
end tell end tell
tell application "Quicksilver" tell application "Quicksilver"

View file

@ -1,5 +1,5 @@
<Module> <Module>
<ModulePrefs title="Tracks" directory_title="Tracks" description="<%= t('integrations.gmail_description') %>" author="Tracks" author_email="butshesagirl@rousette.org.uk" author_affiliation="Tracks" author_location="UK" title_url="http://www.getontracks.org/" screenshot="http://www.getontracks.org/images/uploads/tracks_home_thumb.png" thumbnail="http://www.getontracks.org/images/uploads/tracks_tickler.png" category="communication" category2="tools" height="300"> <ModulePrefs title="Tracks" directory_title="Tracks" description="<%= t('integrations.gmail_description') %>" author="Tracks" author_email="butshesagirl@rousette.org.uk" author_affiliation="Tracks" author_location="UK" title_url="http://www.getontracks.org/" screenshot="http://www.getontracks.org/images/uploads/tracks_home_thumb.png" thumbnail="http://www.getontracks.org/images/uploads/tracks_tickler.png" category="communication" category2="tools" height="300">
</ModulePrefs> </ModulePrefs>
<Content type="url" href="<%= home_url %>mobile"/> <Content type="url" href="<%= root_url %>mobile"/>
</Module> </Module>

View file

@ -90,7 +90,7 @@
<p>If you enter the following entry to your crontab, you will receive email every day around 5 AM with a list of the upcoming actions which are due within the next 7 days.</p> <p>If you enter the following entry to your crontab, you will receive email every day around 5 AM with a list of the upcoming actions which are due within the next 7 days.</p>
<textarea id="cron" name="cron">0 5 * * * /usr/bin/curl -0 "<%= home_url %>todos.txt?due=6&token=<%= current_user.token %>" | /usr/bin/mail -e -s 'Tracks actions due in the next 7 days' youremail@yourdomain.com</textarea> <textarea id="cron" name="cron">0 5 * * * /usr/bin/curl -0 "<%= root_url %>todos.txt?due=6&token=<%= current_user.token %>" | /usr/bin/mail -e -s 'Tracks actions due in the next 7 days' youremail@yourdomain.com</textarea>
<p>You can of course use other text <%= link_to 'feeds provided by Tracks', feeds_path %> -- why not email a list of next actions in a particular project to a group of colleagues who are working on the project?</p> <p>You can of course use other text <%= link_to 'feeds provided by Tracks', feeds_path %> -- why not email a list of next actions in a particular project to a group of colleagues who are working on the project?</p>
@ -100,7 +100,7 @@
If Tracks is running on the same server as your mail server, you can use the integrated mail handler built into tracks. Steps to set it up: If Tracks is running on the same server as your mail server, you can use the integrated mail handler built into tracks. Steps to set it up:
</p> </p>
<ul> <ul>
<li>Go to <%= link_to t('layouts.navigation.preferences'), preferences_url %> <li>Go to <%= link_to t('layouts.navigation.preferences'), preferences_url %>
and set your "<%= Preference.human_attribute_name('sms_email') %>" and and set your "<%= Preference.human_attribute_name('sms_email') %>" and
"<%= Preference.human_attribute_name('sms_context') %>" for todos sent in "<%= Preference.human_attribute_name('sms_context') %>" for todos sent in
via email (which could come from an SMS message)</li> via email (which could come from an SMS message)</li>

View file

@ -15,7 +15,7 @@
<li><a href="#message_gateway">Integrate Tracks with an email server to be able to send an action through email to Tracks</a></li> <li><a href="#message_gateway">Integrate Tracks with an email server to be able to send an action through email to Tracks</a></li>
<li><a href="#google_gadget">Add Tracks as a Google Gmail gadget</a></li> <li><a href="#google_gadget">Add Tracks as a Google Gmail gadget</a></li>
</ul><br/> </ul><br/>
<p>Do you have one of your own to add? <p>Do you have one of your own to add?
<a href="http://www.getontracks.org/forums/viewforum/10/" title="Tracks | Tips and Tricks">Tell us about <a href="http://www.getontracks.org/forums/viewforum/10/" title="Tracks | Tips and Tricks">Tell us about
it in our Tips and Tricks forum</a> and we may include it on this page in a future versions of Tracks. it in our Tips and Tricks forum</a> and we may include it on this page in a future versions of Tracks.
</p> </p>
@ -90,7 +90,7 @@
<p>If you enter the following entry to your crontab, you will receive email every day around 5 AM with a list of the upcoming actions which are due within the next 7 days.</p> <p>If you enter the following entry to your crontab, you will receive email every day around 5 AM with a list of the upcoming actions which are due within the next 7 days.</p>
<textarea id="cron" name="cron">0 5 * * * /usr/bin/curl -0 "<%= home_url %>todos.txt?due=6&token=<%= current_user.token %>" | /usr/bin/mail -e -s 'Tracks actions due in the next 7 days' youremail@yourdomain.com</textarea> <textarea id="cron" name="cron">0 5 * * * /usr/bin/curl -0 "<%= root_url %>todos.txt?due=6&token=<%= current_user.token %>" | /usr/bin/mail -e -s 'Tracks actions due in the next 7 days' youremail@yourdomain.com</textarea>
<p>You can of course use other text <%= link_to 'feeds provided by Tracks', feeds_path %> -- why not email a list of next actions in a particular project to a group of colleagues who are working on the project?</p> <p>You can of course use other text <%= link_to 'feeds provided by Tracks', feeds_path %> -- why not email a list of next actions in a particular project to a group of colleagues who are working on the project?</p>
@ -100,7 +100,7 @@
If Tracks is running on the same server as your mail server, you can use the integrated mail handler built into tracks. Steps to set it up: If Tracks is running on the same server as your mail server, you can use the integrated mail handler built into tracks. Steps to set it up:
</p> </p>
<ul> <ul>
<li>Go to <%= link_to t('layouts.navigation.preferences'), preferences_url %> and <li>Go to <%= link_to t('layouts.navigation.preferences'), preferences_url %> and
set your "<%= Preference.human_attribute_name('sms_email') %>" and set your "<%= Preference.human_attribute_name('sms_email') %>" and
"<%= Preference.human_attribute_name('sms_context') %>" for todos sent in "<%= Preference.human_attribute_name('sms_context') %>" for todos sent in
via email (which could come from an SMS message)</li> via email (which could come from an SMS message)</li>

View file

@ -41,7 +41,7 @@
<a name="applescript2-section"> </a> <a name="applescript2-section"> </a>
<h2>Voeg een acties toe met Applescript op basis van de huidig geselecteerde e-mail in Mail.app</h2> <h2>Voeg een acties toe met Applescript op basis van de huidig geselecteerde e-mail in Mail.app</h2>
<p>Dit script neemt de verstuurder en het onderwerp van de geselecteerde email(s) <p>Dit script neemt de verstuurder en het onderwerp van de geselecteerde email(s)
van Mail over en maakt een nieuwe acties voor elke email met de beschrijving van Mail over en maakt een nieuwe acties voor elke email met de beschrijving
"Email [sender] about [subject]". De beschrijving wordt, als nodig, na 100 karakters afgebroken "Email [sender] about [subject]". De beschrijving wordt, als nodig, na 100 karakters afgebroken
(dit is de limiet voor een beschrijving). Het heeft ook Growl notificaties mocht je Growl geïnstalleerd hebben.</p> (dit is de limiet voor een beschrijving). Het heeft ook Growl notificaties mocht je Growl geïnstalleerd hebben.</p>
@ -93,7 +93,7 @@
<p>Als je de volgende regel toevoegd aan jouw crontab, dat ontvang je een e-mail op elke dag rond 05:00 met een lijst met acties waarvan de deadline afloopt binnen de komende 7 dagen.</p> <p>Als je de volgende regel toevoegd aan jouw crontab, dat ontvang je een e-mail op elke dag rond 05:00 met een lijst met acties waarvan de deadline afloopt binnen de komende 7 dagen.</p>
<textarea id="cron" name="cron">0 5 * * * /usr/bin/curl -0 "<%= home_url %>todos.txt?due=6&token=<%= current_user.token %>" | /usr/bin/mail -e -s 'Tracks actions due in the next 7 days' youremail@yourdomain.com</textarea> <textarea id="cron" name="cron">0 5 * * * /usr/bin/curl -0 "<%= root_url %>todos.txt?due=6&token=<%= current_user.token %>" | /usr/bin/mail -e -s 'Tracks actions due in the next 7 days' youremail@yourdomain.com</textarea>
<p>Uiteraard kan je ook een andere <%= link_to 'text feed gebruiken die Tracks biedt', feeds_path %> -- bijvoorbeeld een email met een lijst van acties voor een specifiek project naar een groep collega's die werken aan dat project?</p> <p>Uiteraard kan je ook een andere <%= link_to 'text feed gebruiken die Tracks biedt', feeds_path %> -- bijvoorbeeld een email met een lijst van acties voor een specifiek project naar een groep collega's die werken aan dat project?</p>
@ -103,7 +103,7 @@
Als Tracks draait op dezelfde server als jouw mailserver, dan kan je de geïntegreerde mail handler gebruiken van Tracks. Om dit in te stellen: Als Tracks draait op dezelfde server als jouw mailserver, dan kan je de geïntegreerde mail handler gebruiken van Tracks. Om dit in te stellen:
</p> </p>
<ul> <ul>
<li>Ga naar <%= link_to t('layouts.navigation.preferences'), preferences_url %> <li>Ga naar <%= link_to t('layouts.navigation.preferences'), preferences_url %>
en stel in "<%= Preference.human_attribute_name('sms_email') %>" en en stel in "<%= Preference.human_attribute_name('sms_email') %>" en
"<%= Preference.human_attribute_name('sms_context') %>" voor acties die "<%= Preference.human_attribute_name('sms_context') %>" voor acties die
verzonden zijn via email (die bijv. komen via een SMS message)</li> verzonden zijn via email (die bijv. komen via een SMS message)</li>
@ -122,7 +122,7 @@
<p> <p>
Je kan nu ook jouw projects/actions beheren in Gmail met de Tracks Gmail Gadget. Je kan nu ook jouw projects/actions beheren in Gmail met de Tracks Gmail Gadget.
Voeg Tracks Gmail gadget toe aan de sidebar van Gmail en volg jouw acties Voeg Tracks Gmail gadget toe aan de sidebar van Gmail en volg jouw acties
of voeg een nieuwe actie toe zonder apart een nieuw browser tab/scherm te openen of voeg een nieuwe actie toe zonder apart een nieuw browser tab/scherm te openen
voor Tracks. Om dit in te stellen: voor Tracks. Om dit in te stellen:
</p> </p>
<ul> <ul>

View file

@ -21,7 +21,7 @@
<pre> <pre>
<code> <code>
$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \ $ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
<%= home_url %>contexts.xml <%= root_url %>contexts.xml
&gt;&gt; &lt;?xml version="1.0" encoding="UTF-8"?&gt; &gt;&gt; &lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;contexts&gt;...&lt;/contexts&gt; &lt;contexts&gt;...&lt;/contexts&gt;
</code> </code>
@ -32,7 +32,7 @@
<pre> <pre>
<code> <code>
$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \ $ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
<%= home_url %>contexts/51.xml <%= root_url %>contexts/51.xml
&gt;&gt; &lt;?xml version="1.0" encoding="UTF-8"?&gt; &gt;&gt; &lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;context&gt;...&lt;/context&gt; &lt;context&gt;...&lt;/context&gt;
</code> </code>
@ -43,7 +43,7 @@
<pre> <pre>
<code> <code>
$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \ $ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
<%= home_url %>contexts/51/todos.xml <%= root_url %>contexts/51/todos.xml
&gt;&gt; &lt;?xml version="1.0" encoding="UTF-8"?&gt; &gt;&gt; &lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;todos type="array"&gt;...&lt;/todos&gt; &lt;todos type="array"&gt;...&lt;/todos&gt;
</code> </code>
@ -75,7 +75,7 @@ field to <code>ID, created_at, modified_at, completed_at</code> by adding the pa
<pre> <pre>
<code> <code>
$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \ $ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
<%= home_url %>tickler.xml?limit_fields=index <%= root_url %>tickler.xml?limit_fields=index
</code> </code>
</pre> </pre>
@ -89,9 +89,9 @@ field to <code>ID, created_at, modified_at, completed_at</code> by adding the pa
<code> <code>
$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \ $ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
-d "&lt;project&gt;&lt;name&gt;Build a treehouse for the kids&lt;/name&gt;&lt;/project&gt;" \ -d "&lt;project&gt;&lt;name&gt;Build a treehouse for the kids&lt;/name&gt;&lt;/project&gt;" \
<%= home_url %>projects.xml -i <%= root_url %>projects.xml -i
&gt;&gt; HTTP/1.1 201 Created &gt;&gt; HTTP/1.1 201 Created
Location: <%= home_url %>projects/65.xml Location: <%= root_url %>projects/65.xml
... ...
</code> </code>
</pre> </pre>
@ -102,9 +102,9 @@ Location: <%= home_url %>projects/65.xml
<code> <code>
$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \ $ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
-d "&lt;todo&gt;&lt;description&gt;Model treehouse in SketchUp&lt;/description&gt;&lt;context_id&gt;2&lt;/context_id&gt;&lt;project_id&gt;65&lt;/project_id&gt;&lt;/todo&gt;" \ -d "&lt;todo&gt;&lt;description&gt;Model treehouse in SketchUp&lt;/description&gt;&lt;context_id&gt;2&lt;/context_id&gt;&lt;project_id&gt;65&lt;/project_id&gt;&lt;/todo&gt;" \
<%= home_url %>todos.xml -i <%= root_url %>todos.xml -i
&gt;&gt; HTTP/1.1 201 Created &gt;&gt; HTTP/1.1 201 Created
Location: <%= home_url %>todos/452.xml Location: <%= root_url %>todos/452.xml
... ...
</code> </code>
</pre> </pre>
@ -115,7 +115,7 @@ Location: <%= home_url %>todos/452.xml
<code> <code>
$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" -X PUT \ $ curl -u username:p4ssw0rd -H "Content-Type: text/xml" -X PUT \
-d "&lt;todo&gt;&lt;notes&gt;use maple texture&lt;/notes&gt;&lt;/todos&gt;" \ -d "&lt;todo&gt;&lt;notes&gt;use maple texture&lt;/notes&gt;&lt;/todos&gt;" \
<%= home_url %>todos/452.xml -i <%= root_url %>todos/452.xml -i
&gt;&gt; HTTP/1.1 200 OK &gt;&gt; HTTP/1.1 200 OK
... ...
@ -135,7 +135,7 @@ Location: <%= home_url %>todos/452.xml
<pre> <pre>
<code> <code>
$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" -X PUT \ $ curl -u username:p4ssw0rd -H "Content-Type: text/xml" -X PUT \
<%= home_url %>todos/452/toggle_check.xml -i <%= root_url %>todos/452/toggle_check.xml -i
&gt;&gt; HTTP/1.1 200 OK &gt;&gt; HTTP/1.1 200 OK
... ...
@ -156,7 +156,7 @@ Location: <%= home_url %>todos/452.xml
<pre> <pre>
<code> <code>
$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" -X DELETE \ $ curl -u username:p4ssw0rd -H "Content-Type: text/xml" -X DELETE \
<%= home_url %>todos/452.xml -i <%= root_url %>todos/452.xml -i
&gt;&gt; HTTP/1.1 200 OK &gt;&gt; HTTP/1.1 200 OK
... ...
</code> </code>
@ -175,7 +175,7 @@ Location: <%= home_url %>todos/452.xml
<pre> <pre>
<code> <code>
$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \ $ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
<%= home_url %>contexts/2/todos.xml <%= root_url %>contexts/2/todos.xml
&gt;&gt; &lt;?xml version="1.0" encoding="UTF-8"?&gt; &gt;&gt; &lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;nil-classes type="array"/&gt; &lt;nil-classes type="array"/&gt;
@ -192,8 +192,8 @@ $ script/console
Loading development environment (Rails 1.2.4) Loading development environment (Rails 1.2.4)
&gt;&gt; class Context &lt; ActiveResource::Base; end &gt;&gt; class Context &lt; ActiveResource::Base; end
=&gt; nil =&gt; nil
&gt;&gt; Context.site = "<%= home_url %>" &gt;&gt; Context.site = "<%= root_url %>"
=&gt; "<%= home_url %>" =&gt; "<%= root_url %>"
&gt;&gt; Context.site.user = "username" &gt;&gt; Context.site.user = "username"
=&gt; "username" =&gt; "username"

View file

@ -7,7 +7,7 @@ form_for(note, :html => {
:class => "inline-form edit-note-form"}) do |f| :class => "inline-form edit-note-form"}) do |f|
-%> -%>
<div id="error_status"><%= error_messages_for("note") %></div> <div id="error_status"><%= get_list_of_error_messages_for(note) %></div>
<%= f.hidden_field( "project_id" ) %> <%= f.hidden_field( "project_id" ) %>
<%= f.text_area( "body", "cols" => 70, "rows" => 15, "tabindex" => 1 ) %> <%= f.text_area( "body", "cols" => 70, "rows" => 15, "tabindex" => 1 ) %>

View file

@ -7,7 +7,7 @@
<div id="project_new" class="project_new" style="display:block"> <div id="project_new" class="project_new" style="display:block">
<%= form_for(@new_project, :html => {:id => 'project_form',:name=>'project',:class => "inline-form", :method => :post }) do -%> <%= form_for(@new_project, :html => {:id => 'project_form',:name=>'project',:class => "inline-form", :method => :post }) do -%>
<div id="error_status"><%= error_messages_for("project") %></div> <div id="error_status"><%= get_list_of_error_messages_for(@new_project) %></div>
<label for="project_name"><%= Project.human_attribute_name(:name) %>:</label><br /> <label for="project_name"><%= Project.human_attribute_name(:name) %>:</label><br />
<%= text_field 'project', 'name', "tabindex" => next_tab_index %><br /> <%= text_field 'project', 'name', "tabindex" => next_tab_index %><br />

View file

@ -5,7 +5,7 @@
<% end -%> <% end -%>
<div id="project_name" style="width: 100%;"><%= project.name -%></div> <div id="project_name" style="width: 100%;"><%= project.name -%></div>
</h2> </h2>
<div id="<%= dom_id(project, "container")%>" class="list"><%-# list needs to be here for edit form to work -%> <div id="<%= dom_id(project, "container")%>" class="list">
<%= render :partial => "projects/project_settings", :object => project, :locals => { :collapsible => collapsible } %> <%= render :partial => "projects/project_settings", :object => project, :locals => { :collapsible => collapsible } %>
</div> </div>
</div> </div>
@ -18,4 +18,4 @@
</div> </div>
<%= render :partial => "todos/todo", :collection => @not_done, :locals => { :parent_container_type => "project" } %> <%= render :partial => "todos/todo", :collection => @not_done, :locals => { :parent_container_type => "project" } %>
</div> </div>
</div> </div>

View file

@ -7,7 +7,7 @@ project = project_form
:class => "inline-form edit-project-form", :class => "inline-form edit-project-form",
:method => :put }) do :method => :put }) do
-%> -%>
<div id="edit_error_status"><%= error_messages_for("project") %></div> <div id="edit_error_status"><%= get_list_of_error_messages_for(@project) %></div>
<%= source_view_tag( @source_view ) -%> <%= source_view_tag( @source_view ) -%>
<label for="project_name">Name:</label><br/> <label for="project_name">Name:</label><br/>

View file

@ -37,7 +37,7 @@ function update_active_projects_container() {
} }
function html_for_error_messages() { function html_for_error_messages() {
return "<%= escape_javascript(error_messages_for('project')) %>"; return "<%= escape_javascript(get_list_of_error_messages_for(@project)) %>";
} }
function html_for_project_listing() { function html_for_project_listing() {

View file

@ -0,0 +1,12 @@
atom_feed do |feed|
feed.title(@feed_title)
feed.subtitle(@feed_description)
feed.updated(@projects.last.updated_at)
@projects.each do |project|
feed.entry(project) do |entry|
entry.title(h(project.name))
entry.content(project_summary(project), :type => :html)
end
end
end

View file

@ -0,0 +1,20 @@
xml.instruct! :xml, :version => "1.0"
xml.rss :version => "2.0" do
xml.channel do
xml.title @feed_title
xml.description @feed_description
xml.link contexts_url
xml.language 'en-us'
xml.ttl 40
@projects.each do |project|
xml.item do
xml.title h(project.name)
xml.description project_summary(project)
xml.pubDate project.created_at.to_s(:rfc822)
xml.link project_url(project)
xml.guid project_url(project)
end
end
end
end

View file

@ -14,8 +14,7 @@
<div class="add_note_link"><%= link_to t('projects.add_note'), '#' %> </div> <div class="add_note_link"><%= link_to t('projects.add_note'), '#' %> </div>
<h2><%= t('projects.notes') %></h2> <h2><%= t('projects.notes') %></h2>
<div id="empty-n" style="display:<%= @project.notes.empty? ? 'block' : 'none'%>;"> <div id="empty-n" style="display:<%= @project.notes.empty? ? 'block' : 'none'%>;">
<%= render :partial => "shared/empty", <div class="message"><p><%= t('projects.no_notes_attached') %></p></div>
:locals => { :message => t('projects.no_notes_attached')} %>
</div> </div>
<%= render :partial => "notes/notes_summary", :collection => @project.notes %> <%= render :partial => "notes/notes_summary", :collection => @project.notes %>
</div> </div>
@ -29,5 +28,5 @@
<div id="input_box"> <div id="input_box">
<%= render :partial => "shared/add_new_item_form" %> <%= render :partial => "shared/add_new_item_form" %>
<%= render :file => "sidebar/sidebar.html.erb" %> <%= render :file => "sidebar/sidebar" %>
</div><!-- End of input box --> </div><!-- End of input box -->

View file

@ -1,3 +0,0 @@
<div class="message">
<p><%= message %></p>
</div>

View file

@ -1,5 +1,7 @@
module Tracks module Tracks
class Config class Config
def self.salt def self.salt
SITE_CONFIG['salt'] SITE_CONFIG['salt']
end end
@ -15,7 +17,7 @@ module Tracks
def self.cas_enabled? def self.cas_enabled?
auth_schemes.include?('cas') auth_schemes.include?('cas')
end end
def self.prefered_auth? def self.prefered_auth?
if SITE_CONFIG['prefered_auth'] if SITE_CONFIG['prefered_auth']
SITE_CONFIG['prefered_auth'] SITE_CONFIG['prefered_auth']
@ -23,5 +25,7 @@ module Tracks
auth_schemes.first auth_schemes.first
end end
end end
end end
end end

View file

@ -1,16 +1,8 @@
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
require 'integrations_controller'
# Re-raise errors caught by the controller.
class IntegrationsController; def rescue_action(e) raise e end; end
class IntegrationsControllerTest < ActionController::TestCase class IntegrationsControllerTest < ActionController::TestCase
fixtures :users, :preferences, :projects, :contexts, :todos, :recurring_todos, :tags, :taggings
def setup def setup
@controller = IntegrationsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end end
def test_page_load def test_page_load
@ -22,15 +14,15 @@ class IntegrationsControllerTest < ActionController::TestCase
def test_cloudmailin_integration_success def test_cloudmailin_integration_success
SITE_CONFIG['cloudmailin'] = "123456789" SITE_CONFIG['cloudmailin'] = "123456789"
post :cloudmailin, { post :cloudmailin, {
"html"=>"", "html"=>"",
"plain"=>"asdasd", "plain"=>"asdasd",
"x_to_header"=>"[\"81496ecea21032d35a7a@cloudmailin.net\"]", "x_to_header"=>"[\"81496ecea21032d35a7a@cloudmailin.net\"]",
"disposable"=>"", "disposable"=>"",
"from"=>"5555555555@tmomail.net", "from"=>"5555555555@tmomail.net",
"signature"=>"e85e908fb893394762047c21e54ce248", "signature"=>"e85e908fb893394762047c21e54ce248",
"to"=>"<123123@cloudmailin.net>", "to"=>"<123123@cloudmailin.net>",
"subject"=>"asd", "subject"=>"asd",
"x_cc_header"=>"", "x_cc_header"=>"",
"message"=>"Received: from VMBX103.ihostexchange.net ([192.168.3.3]) by\r\n HUB103.ihostexchange.net ([66.46.182.53]) with mapi; Wed, 5 Oct 2011 17:12:44\r\n -0400\r\nFrom: SMS User <5555555555@tmomail.net>\r\nTo: Tracks <123123@cloudmailin.net>\r\nDate: Wed, 5 Oct 2011 17:12:43 -0400\r\nSubject: asd\r\nThread-Topic: asd\r\nThread-Index: AcyDo4aig2wghvcsTAOkleWqi4t/FQ==\r\nMessage-ID: <7D7CB176-7559-4997-A301-8DF9726264C7@tmomail.net>\r\nAccept-Language: de-DE, en-US\r\nContent-Language: en-US\r\nX-MS-Has-Attach:\r\nX-MS-TNEF-Correlator:\r\nacceptlanguage: de-DE, en-US\r\nContent-Type: text/plain; charset=\"us-ascii\"\r\nContent-Transfer-Encoding: quoted-printable\r\nMIME-Version: 1.0\r\n\r\nasdasd\r\n" "message"=>"Received: from VMBX103.ihostexchange.net ([192.168.3.3]) by\r\n HUB103.ihostexchange.net ([66.46.182.53]) with mapi; Wed, 5 Oct 2011 17:12:44\r\n -0400\r\nFrom: SMS User <5555555555@tmomail.net>\r\nTo: Tracks <123123@cloudmailin.net>\r\nDate: Wed, 5 Oct 2011 17:12:43 -0400\r\nSubject: asd\r\nThread-Topic: asd\r\nThread-Index: AcyDo4aig2wghvcsTAOkleWqi4t/FQ==\r\nMessage-ID: <7D7CB176-7559-4997-A301-8DF9726264C7@tmomail.net>\r\nAccept-Language: de-DE, en-US\r\nContent-Language: en-US\r\nX-MS-Has-Attach:\r\nX-MS-TNEF-Correlator:\r\nacceptlanguage: de-DE, en-US\r\nContent-Type: text/plain; charset=\"us-ascii\"\r\nContent-Transfer-Encoding: quoted-printable\r\nMIME-Version: 1.0\r\n\r\nasdasd\r\n"
} }
@ -40,15 +32,15 @@ class IntegrationsControllerTest < ActionController::TestCase
def test_cloudmailin_integration_invalid_signature def test_cloudmailin_integration_invalid_signature
SITE_CONFIG['cloudmailin'] = "12345678901234567890" SITE_CONFIG['cloudmailin'] = "12345678901234567890"
post :cloudmailin, { post :cloudmailin, {
"html"=>"", "html"=>"",
"plain"=>"asdasd", "plain"=>"asdasd",
"x_to_header"=>"[\"81496ecea21032d35a7a@cloudmailin.net\"]", "x_to_header"=>"[\"81496ecea21032d35a7a@cloudmailin.net\"]",
"disposable"=>"", "disposable"=>"",
"from"=>"5555555555@tmomail.net", "from"=>"5555555555@tmomail.net",
"signature"=>"e85e908fb893394762047c21e54ce248", "signature"=>"e85e908fb893394762047c21e54ce248",
"to"=>"<123123@cloudmailin.net>", "to"=>"<123123@cloudmailin.net>",
"subject"=>"asd", "subject"=>"asd",
"x_cc_header"=>"", "x_cc_header"=>"",
"message"=>"Received: from VMBX103.ihostexchange.net ([192.168.3.3]) by\r\n HUB103.ihostexchange.net ([66.46.182.53]) with mapi; Wed, 5 Oct 2011 17:12:44\r\n -0400\r\nFrom: SMS User <5555555555@tmomail.net>\r\nTo: Tracks <123123@cloudmailin.net>\r\nDate: Wed, 5 Oct 2011 17:12:43 -0400\r\nSubject: asd\r\nThread-Topic: asd\r\nThread-Index: AcyDo4aig2wghvcsTAOkleWqi4t/FQ==\r\nMessage-ID: <7D7CB176-7559-4997-A301-8DF9726264C7@tmomail.net>\r\nAccept-Language: de-DE, en-US\r\nContent-Language: en-US\r\nX-MS-Has-Attach:\r\nX-MS-TNEF-Correlator:\r\nacceptlanguage: de-DE, en-US\r\nContent-Type: text/plain; charset=\"us-ascii\"\r\nContent-Transfer-Encoding: quoted-printable\r\nMIME-Version: 1.0\r\n\r\nasdasd\r\n" "message"=>"Received: from VMBX103.ihostexchange.net ([192.168.3.3]) by\r\n HUB103.ihostexchange.net ([66.46.182.53]) with mapi; Wed, 5 Oct 2011 17:12:44\r\n -0400\r\nFrom: SMS User <5555555555@tmomail.net>\r\nTo: Tracks <123123@cloudmailin.net>\r\nDate: Wed, 5 Oct 2011 17:12:43 -0400\r\nSubject: asd\r\nThread-Topic: asd\r\nThread-Index: AcyDo4aig2wghvcsTAOkleWqi4t/FQ==\r\nMessage-ID: <7D7CB176-7559-4997-A301-8DF9726264C7@tmomail.net>\r\nAccept-Language: de-DE, en-US\r\nContent-Language: en-US\r\nX-MS-Has-Attach:\r\nX-MS-TNEF-Correlator:\r\nacceptlanguage: de-DE, en-US\r\nContent-Type: text/plain; charset=\"us-ascii\"\r\nContent-Transfer-Encoding: quoted-printable\r\nMIME-Version: 1.0\r\n\r\nasdasd\r\n"
} }
@ -58,18 +50,19 @@ class IntegrationsControllerTest < ActionController::TestCase
def test_cloudmailin_integration_unknown_address def test_cloudmailin_integration_unknown_address
SITE_CONFIG['cloudmailin'] = "123456789" SITE_CONFIG['cloudmailin'] = "123456789"
post :cloudmailin, { post :cloudmailin, {
"html"=>"", "html"=>"",
"plain"=>"asdasd", "plain"=>"asdasd",
"x_to_header"=>"[\"81496ecea21032d35a7a@cloudmailin.net\"]", "x_to_header"=>"[\"81496ecea21032d35a7a@cloudmailin.net\"]",
"disposable"=>"", "disposable"=>"",
"from"=>"444444444444@tmomail.net", "from"=>"444444444444@tmomail.net",
"signature"=>"6d2df0e807bfa9b77d24c31dce6d4515", "signature"=>"6d2df0e807bfa9b77d24c31dce6d4515",
"to"=>"<123123@cloudmailin.net>", "to"=>"<123123@cloudmailin.net>",
"subject"=>"asd", "subject"=>"asd",
"x_cc_header"=>"", "x_cc_header"=>"",
"message"=>"Received: from VMBX103.ihostexchange.net ([192.168.3.3]) by\r\n HUB103.ihostexchange.net ([66.46.182.53]) with mapi; Wed, 5 Oct 2011 17:12:44\r\n -0400\r\nFrom: SMS User <444444444444@tmomail.net>\r\nTo: Tracks <123123@cloudmailin.net>\r\nDate: Wed, 5 Oct 2011 17:12:43 -0400\r\nSubject: asd\r\nThread-Topic: asd\r\nThread-Index: AcyDo4aig2wghvcsTAOkleWqi4t/FQ==\r\nMessage-ID: <7D7CB176-7559-4997-A301-8DF9726264C7@tmomail.net>\r\nAccept-Language: de-DE, en-US\r\nContent-Language: en-US\r\nX-MS-Has-Attach:\r\nX-MS-TNEF-Correlator:\r\nacceptlanguage: de-DE, en-US\r\nContent-Type: text/plain; charset=\"us-ascii\"\r\nContent-Transfer-Encoding: quoted-printable\r\nMIME-Version: 1.0\r\n\r\nasdasd\r\n" "message"=>"Received: from VMBX103.ihostexchange.net ([192.168.3.3]) by\r\n HUB103.ihostexchange.net ([66.46.182.53]) with mapi; Wed, 5 Oct 2011 17:12:44\r\n -0400\r\nFrom: SMS User <444444444444@tmomail.net>\r\nTo: Tracks <123123@cloudmailin.net>\r\nDate: Wed, 5 Oct 2011 17:12:43 -0400\r\nSubject: asd\r\nThread-Topic: asd\r\nThread-Index: AcyDo4aig2wghvcsTAOkleWqi4t/FQ==\r\nMessage-ID: <7D7CB176-7559-4997-A301-8DF9726264C7@tmomail.net>\r\nAccept-Language: de-DE, en-US\r\nContent-Language: en-US\r\nX-MS-Has-Attach:\r\nX-MS-TNEF-Correlator:\r\nacceptlanguage: de-DE, en-US\r\nContent-Type: text/plain; charset=\"us-ascii\"\r\nContent-Transfer-Encoding: quoted-printable\r\nMIME-Version: 1.0\r\n\r\nasdasd\r\n"
} }
assert_response 404 assert_response 404
end end
end end

View file

@ -1,19 +1,9 @@
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
require 'login_controller'
require_dependency "login_system"
# Re-raise errors caught by the controller.
class LoginController; def rescue_action(e) raise e end; end
class LoginControllerTest < ActionController::TestCase class LoginControllerTest < ActionController::TestCase
fixtures :preferences, :users fixtures :preferences, :users
def setup def setup
assert_equal "test", ENV['RAILS_ENV']
assert_equal "change-me", Tracks::Config.salt
@controller = LoginController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end end
#============================================ #============================================
@ -23,15 +13,16 @@ class LoginControllerTest < ActionController::TestCase
def test_invalid_login def test_invalid_login
post :login, {:user_login => 'cracker', :user_password => 'secret', :user_noexpiry => 'on'} post :login, {:user_login => 'cracker', :user_password => 'secret', :user_noexpiry => 'on'}
assert_response :success assert_response :success
assert(!@response.has_session_object?(:user_id)) assert(!session[:user_id])
assert_template "login" assert_template "login"
end end
def test_login_with_valid_admin_user def test_login_with_valid_admin_user
@request.session['return-to'] = "/bogus/location" @request.session['return-to'] = "/bogus/location"
post :login, {:user_login => 'admin', :user_password => 'abracadabra', :user_noexpiry => 'on'} post :login, {:user_login => 'admin', :user_password => 'abracadabra', :user_noexpiry => 'on'}
user = User.find(session['user_id']) user = User.find_by_id(session['user_id'])
assert_equal user.id, @response.session['user_id'] assert_not_nil user
assert_equal user.id, session['user_id']
assert_equal user.login, "admin" assert_equal user.login, "admin"
assert user.is_admin assert user.is_admin
assert_equal "Login successful: session will not expire.", flash[:notice] assert_equal "Login successful: session will not expire.", flash[:notice]
@ -40,12 +31,13 @@ class LoginControllerTest < ActionController::TestCase
def test_login_with_valid_standard_user def test_login_with_valid_standard_user
post :login, {:user_login => 'jane', :user_password => 'sesame', :user_noexpiry => 'off'} post :login, {:user_login => 'jane', :user_password => 'sesame', :user_noexpiry => 'off'}
user = User.find(session['user_id']) user = User.find_by_id(session['user_id'])
assert_equal user.id, @response.session['user_id'] assert_not_nil user
assert_equal user.id, session['user_id']
assert_equal user.login, "jane" assert_equal user.login, "jane"
assert user.is_admin == false || user.is_admin == 0 assert user.is_admin == false || user.is_admin == 0
assert_equal "Login successful: session will expire after 1 hour of inactivity.", flash[:notice] assert_equal "Login successful: session will expire after 1 hour of inactivity.", flash[:notice]
assert_redirected_to home_url assert_redirected_to root_url
end end
def test_login_with_no_users_redirects_to_signup def test_login_with_no_users_redirects_to_signup
@ -58,21 +50,21 @@ class LoginControllerTest < ActionController::TestCase
login_as :admin_user login_as :admin_user
get :logout get :logout
assert_nil(session['user_id']) assert_nil(session['user_id'])
assert_redirected_to :controller => 'login', :action => 'login' assert_redirected_to login_url
end end
# Test login with a bad password for existing user # Test login with a bad password for existing user
# #
def test_login_bad_password def test_login_bad_password
post :login, {:user_login => 'jane', :user_password => 'wrong', :user_noexpiry => 'on'} post :login, {:user_login => 'jane', :user_password => 'wrong', :user_noexpiry => 'on'}
assert(!@response.has_session_object?(:user)) assert(!session[:user])
assert_equal "Login unsuccessful.", flash[:warning] assert_equal "Login unsuccessful.", flash[:warning]
assert_response :success assert_response :success
end end
def test_login_bad_login def test_login_bad_login
post :login, {:user_login => 'blah', :user_password => 'sesame', :user_noexpiry => 'on'} post :login, {:user_login => 'blah', :user_password => 'sesame', :user_noexpiry => 'on'}
assert(!@response.has_session_object?(:user)) assert(!session[:user])
assert_equal "Login unsuccessful.", flash[:warning] assert_equal "Login unsuccessful.", flash[:warning]
assert_response :success assert_response :success
end end
@ -81,7 +73,7 @@ class LoginControllerTest < ActionController::TestCase
post :login, :user_login => 'jane', :user_password => 'sesame', :user_noexpiry => "on" post :login, :user_login => 'jane', :user_password => 'sesame', :user_noexpiry => "on"
assert_not_nil @response.cookies["auth_token"] assert_not_nil @response.cookies["auth_token"]
end end
def test_should_not_remember_me def test_should_not_remember_me
post :login, :user_login => 'jane', :user_password => 'sesame', :user_noexpiry => "off" post :login, :user_login => 'jane', :user_password => 'sesame', :user_noexpiry => "off"
assert_nil @response.cookies["auth_token"] assert_nil @response.cookies["auth_token"]
@ -92,14 +84,14 @@ class LoginControllerTest < ActionController::TestCase
get :logout get :logout
assert_nil @response.cookies["auth_token"] assert_nil @response.cookies["auth_token"]
end end
def test_should_login_with_cookie def test_should_login_with_cookie
users(:other_user).remember_me users(:other_user).remember_me
@request.cookies["auth_token"] = auth_token_cookie_for(:other_user) @request.cookies["auth_token"] = auth_token_cookie_for(:other_user)
get :login get :login
assert @controller.send(:logged_in?) assert @controller.send(:logged_in?)
end end
def test_should_fail_expired_cookie_login def test_should_fail_expired_cookie_login
users(:other_user).remember_me users(:other_user).remember_me
users(:other_user).update_attribute :remember_token_expires_at, 5.minutes.ago.utc users(:other_user).update_attribute :remember_token_expires_at, 5.minutes.ago.utc
@ -107,7 +99,7 @@ class LoginControllerTest < ActionController::TestCase
get :login get :login
assert !@controller.send(:logged_in?) assert !@controller.send(:logged_in?)
end end
def test_should_fail_cookie_login def test_should_fail_cookie_login
users(:other_user).remember_me users(:other_user).remember_me
@request.cookies["auth_token"] = 'invalid_auth_token' @request.cookies["auth_token"] = 'invalid_auth_token'
@ -137,10 +129,9 @@ class LoginControllerTest < ActionController::TestCase
end end
private private
def auth_token_cookie_for(user) def auth_token_cookie_for(user)
users(user).remember_token users(user).remember_token
end end
end end

View file

@ -1,15 +1,8 @@
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
require File.expand_path(File.dirname(__FILE__) + '/todo_container_controller_test_base')
require 'projects_controller'
# Re-raise errors caught by the controller. class ProjectsControllerTest < ActionController::TestCase
class ProjectsController; def rescue_action(e) raise e end; end
class ProjectsControllerTest < TodoContainerControllerTestBase
fixtures :users, :todos, :preferences, :projects, :contexts, :recurring_todos
def setup def setup
perform_setup(Project, ProjectsController)
end end
def test_projects_list def test_projects_list
@ -23,35 +16,32 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
get :show, :id => p.to_param get :show, :id => p.to_param
assert_not_nil assigns['deferred'] assert_not_nil assigns['deferred']
assert_equal 1, assigns['deferred'].size assert_equal 1, assigns['deferred'].size
t = p.todos.not_completed[0] t = p.todos.not_completed[0]
t.show_from = 1.days.from_now.utc t.show_from = 1.days.from_now.utc
t.save! t.save!
get :show, :id => p.to_param get :show, :id => p.to_param
assert_equal 2, assigns['deferred'].size assert_equal 2, assigns['deferred'].size
end end
def test_show_exposes_next_project_in_same_state def test_show_exposes_next_project_in_same_state
login_as :admin_user login_as :admin_user
get :show, :id => projects(:timemachine).to_param get :show, :id => projects(:timemachine).to_param
assert_equal(projects(:moremoney), assigns['next_project']) assert_equal(projects(:moremoney), assigns['next_project'])
end end
def test_show_exposes_previous_project_in_same_state def test_show_exposes_previous_project_in_same_state
login_as :admin_user login_as :admin_user
get :show, :id => projects(:moremoney).to_param get :show, :id => projects(:moremoney).to_param
assert_equal(projects(:timemachine), assigns['previous_project']) assert_equal(projects(:timemachine), assigns['previous_project'])
end end
def test_create_project_via_ajax_increments_number_of_projects def test_create_project_via_ajax_increments_number_of_projects
login_as :other_user
assert_ajax_create_increments_count 'My New Project' assert_ajax_create_increments_count 'My New Project'
end end
def test_create_with_comma_in_name_increments_number_of_projects
assert_ajax_create_increments_count 'foo,bar'
end
def test_todo_state_is_project_hidden_after_hiding_project def test_todo_state_is_project_hidden_after_hiding_project
p = projects(:timemachine) p = projects(:timemachine)
todos = p.todos.find_in_state(:all, :active) todos = p.todos.find_in_state(:all, :active)
@ -75,12 +65,14 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
assert p.reload().active? assert p.reload().active?
end end
# RSS
def test_rss_feed_content def test_rss_feed_content
login_as(:admin_user) login_as(:admin_user)
get :index, { :format => "rss" } get :index, { :format => "rss" }
assert_equal 'application/rss+xml', @response.content_type assert_equal 'application/rss+xml', @response.content_type
#puts @response.body #puts @response.body
assert_xml_select 'rss[version="2.0"]' do assert_xml_select 'rss[version="2.0"]' do
assert_select 'channel' do assert_select 'channel' do
assert_select '>title', 'Tracks Projects' assert_select '>title', 'Tracks Projects'
@ -102,7 +94,7 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
end end
end end
end end
def test_rss_feed_not_accessible_to_anonymous_user_without_token def test_rss_feed_not_accessible_to_anonymous_user_without_token
login_as nil login_as nil
get :index, { :format => "rss" } get :index, { :format => "rss" }
@ -125,8 +117,8 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
login_as :admin_user login_as :admin_user
get :index, { :format => "atom" } get :index, { :format => "atom" }
assert_equal 'application/atom+xml', @response.content_type assert_equal 'application/atom+xml', @response.content_type
#puts @response.body # puts @response.body
assert_xml_select 'feed[xmlns="http://www.w3.org/2005/Atom"]' do assert_xml_select 'feed[xmlns="http://www.w3.org/2005/Atom"]' do
assert_select '>title', 'Tracks Projects' assert_select '>title', 'Tracks Projects'
assert_select '>subtitle', "Lists all the projects for #{users(:admin_user).display_name}" assert_select '>subtitle', "Lists all the projects for #{users(:admin_user).display_name}"
@ -159,7 +151,7 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
get :index, { :format => "atom", :token => users(:admin_user).token } get :index, { :format => "atom", :token => users(:admin_user).token }
assert_response :ok assert_response :ok
end end
def test_text_feed_content def test_text_feed_content
login_as :admin_user login_as :admin_user
get :index, { :format => "txt" } get :index, { :format => "txt" }
@ -171,10 +163,10 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
login_as :admin_user login_as :admin_user
p = projects(:timemachine) p = projects(:timemachine)
p.todos.each { |t| t.destroy } p.todos.each { |t| t.destroy }
get :index, { :format => "txt", :only_active_with_no_next_actions => true } get :index, { :format => "txt", :only_active_with_no_next_actions => true }
assert (/^\s*BUILD A WORKING TIME MACHINE\s+0 actions. Project is active.\s*$/.match(@response.body)) assert (/^\s*BUILD A WORKING TIME MACHINE\s+0 actions. Project is active.\s*$/.match(@response.body))
assert !(/[1-9] actions/.match(@response.body)) assert !(/[1-9] actions/.match(@response.body))
end end
def test_text_feed_not_accessible_to_anonymous_user_without_token def test_text_feed_not_accessible_to_anonymous_user_without_token
@ -194,12 +186,12 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
get :index, { :format => "txt", :token => users(:admin_user).token } get :index, { :format => "txt", :token => users(:admin_user).token }
assert_response :ok assert_response :ok
end end
def test_actionize_sorts_active_projects_by_number_of_tasks def test_actionize_sorts_active_projects_by_number_of_tasks
login_as :admin_user login_as :admin_user
u = users(:admin_user) u = users(:admin_user)
post :actionize, :state => "active", :format => 'js' post :actionize, :state => "active", :format => 'js'
assert_equal 1, projects(:gardenclean).position assert_equal 1, projects(:gardenclean).position
assert_equal 2, projects(:moremoney).position assert_equal 2, projects(:moremoney).position
assert_equal 3, projects(:timemachine).position assert_equal 3, projects(:timemachine).position
@ -211,15 +203,15 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
post :alphabetize, :state => "active", :format => 'js' post :alphabetize, :state => "active", :format => 'js'
assert_equal 1, projects(:timemachine).position assert_equal 1, projects(:timemachine).position
assert_equal 2, projects(:gardenclean).position assert_equal 2, projects(:gardenclean).position
assert_equal 3, projects(:moremoney).position assert_equal 3, projects(:moremoney).position
end end
def test_alphabetize_assigns_state def test_alphabetize_assigns_state
login_as :admin_user login_as :admin_user
post :alphabetize, :state => "active", :format => 'js' post :alphabetize, :state => "active", :format => 'js'
assert_equal "active", assigns['state'] assert_equal "active", assigns['state']
end end
def test_alphabetize_assigns_projects def test_alphabetize_assigns_projects
login_as :admin_user login_as :admin_user
post :alphabetize, :state => "active", :format => 'js' post :alphabetize, :state => "active", :format => 'js'
@ -230,7 +222,4 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
assert_equal projects(:moremoney), exposed_projects[2] assert_equal projects(:moremoney), exposed_projects[2]
end end
def protect_against_forgery?
false
end
end end

View file

@ -112,7 +112,7 @@ class UsersControllerTest < ActionController::TestCase
def test_create_redirects_to_home_page def test_create_redirects_to_home_page
login_as :admin_user login_as :admin_user
post :create, :user => {:login => 'newbie', :password => 'newbiepass', :password_confirmation => 'newbiepass'} post :create, :user => {:login => 'newbie', :password => 'newbiepass', :password_confirmation => 'newbiepass'}
assert_redirected_to home_url assert_redirected_to root_url
end end
def test_create_sets_flash_message def test_create_sets_flash_message

View file

@ -2,6 +2,8 @@ ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__) require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help' require 'rails/test_help'
{ :salt => "change-me", :authentication_schemes => ["database", "open_id"], :prefered_auth => "database"}.each{|k,v| SITE_CONFIG[k]=v}
class ActiveSupport::TestCase class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
# #
@ -15,17 +17,7 @@ class ActiveSupport::TestCase
yield yield
assert_not_equal initial_value, object.send(method), "#{object}##{method}" assert_not_equal initial_value, object.send(method), "#{object}##{method}"
end end
end
module Tracks
class Config
def self.salt
"change-me"
end
def self.auth_schemes
return ["database","open_id"]
end
end
end end
class ActionController::TestCase class ActionController::TestCase