Merge branch 'master' into rails4

Conflicts:
	Gemfile.lock
	config/routes.rb
This commit is contained in:
Reinier Balt 2013-06-17 09:25:02 +02:00
commit 4a485558e2
51 changed files with 5475 additions and 5015 deletions

View file

@ -235,6 +235,52 @@ class RecurringTodosControllerTest < ActionController::TestCase
assert_equal true, recurring_todo.show_always?
end
def test_start_on_monthly_rec_todo
Timecop.travel(Time.local(2012,1,1)) do
login_as(:admin_user)
put :create,
"context_name"=>"library",
"project_name"=>"Build a working time machine",
"recurring_todo" =>
{
"daily_every_x_days"=>"1",
"daily_selector"=>"daily_every_x_day",
"description"=>"new recurring pattern",
"end_date" => nil,
"ends_on" => "no_end_date",
"monthly_day_of_week" => "2",
"monthly_every_x_day" => "2",
"monthly_every_x_month2" => "1",
"monthly_every_x_month" => "3",
"monthly_every_xth_day"=>"1",
"monthly_selector"=>"monthly_every_x_day",
"notes"=>"with some notes",
"number_of_occurences" => nil,
"recurring_period"=>"monthly",
"recurring_show_days_before"=>"0",
"recurring_target"=>"show_from_date",
"recurring_show_always" => "1",
"start_from"=>"2/1/2013",
"weekly_every_x_week"=>"1",
"weekly_return_monday"=>"m",
"yearly_day_of_week"=>"1",
"yearly_every_x_day"=>"8",
"yearly_every_xth_day"=>"1",
"yearly_month_of_year2"=>"8",
"yearly_month_of_year"=>"6",
"yearly_selector"=>"yearly_every_x_day"
},
"tag_list"=>"one, two, three, four"
assert_equal "new recurring pattern", assigns['recurring_todo'].description
assert_equal "2013-01-02 00:00:00 +0000", assigns['recurring_todo'].start_from.to_s
todo = assigns['recurring_todo'].todos.first
assert_equal "2013-01-02 00:00:00 +0000", todo.show_from.to_s
end
end
def test_find_and_inactivate
login_as(:admin_user)

View file

@ -120,6 +120,28 @@ class TodosControllerTest < ActionController::TestCase
assert_response :success
assert_equal 3, @tagged
end
def test_find_tagged_with_terms_separated_with_dot
login_as :admin_user
create_todo(description: "test dotted tag", tag_list: "first.last, second")
t = assigns['todo']
assert_equal "first.last, second", t.tag_list
get :tag, name: 'first.last.m'
assert_equal "text/html", request.format, "controller should set right content type"
assert_equal "text/html", @response.content_type
assert_equal "first.last", assigns['tag_name'], ".m should be chomped"
get :tag, name: 'first.last.txt'
assert_equal "text/plain", request.format, "controller should set right content type"
assert_equal "text/plain", @response.content_type
assert_equal "first.last", assigns['tag_name'], ".txt should be chomped"
get :tag, name: 'first.last'
assert_equal "text/html", request.format, "controller should set right content type"
assert_equal "text/html", @response.content_type
assert_equal "first.last", assigns['tag_name'], ":name should be correct"
end
def test_get_boolean_expression_from_parameters_of_tag_view_single_tag
login_as(:admin_user)
@ -669,7 +691,7 @@ class TodosControllerTest < ActionController::TestCase
recurring_todo_1 = RecurringTodo.find(1)
#set_user_to_current_time_zone(recurring_todo_1.user)
todo_1 = Todo.where(:recurring_todo_id => 1).first
today = Time.zone.now.at_midnight
today = Time.zone.now.at_midnight - 1.day
# change recurrence pattern to monthly and set show_from to today
recurring_todo_1.target = 'show_from_date'
@ -708,7 +730,7 @@ class TodosControllerTest < ActionController::TestCase
assert !new_todo.show_from.nil?
# do not use today here. It somehow gets messed up with the timezone calculation.
next_month = (Time.zone.now + 1.month).at_midnight
next_month = (Time.zone.now - 1.day + 1.month).at_midnight
assert_equal next_month.utc.to_date.to_s(:db), new_todo.show_from.utc.to_date.to_s(:db)
end
@ -920,4 +942,19 @@ class TodosControllerTest < ActionController::TestCase
assert t4.pending?, "t4 should remain pending"
assert t4.predecessors.map(&:id).include?(t3.id)
end
private
def create_todo(params={})
defaults = { source_view: 'todo',
context_name: "library", project_name: "Build a working time machine",
notes: "note", description: "a new todo", due: nil, tag_list: "a,b,c"}
params=params.reverse_merge(defaults)
put :create, _source_view: params[:_source_view],
context_name: params[:context_name], project_name: params[:project_name], tag_list: params[:tag_list],
todo: {notes: params[:notes], description: params[:description], due: params[:due]}
end
end