Skip to content

Commit c5f9fdf

Browse files
committed
Fixed tests which were failing from my last changes.
1 parent a36fcb5 commit c5f9fdf

File tree

7 files changed

+16
-23
lines changed

7 files changed

+16
-23
lines changed

app/controllers/tasks_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,10 @@ def get_default_watchers_for_project
305305
if !params[:id].blank?
306306
@task = AbstractTask.accessed_by(current_user).find_by_id(params[:id])
307307
end
308+
users = []
308309
if params[:project_id].present?
309-
@default_users = User.joins("INNER JOIN default_project_users on default_project_users.user_id = users.id").where("default_project_users.project_id = ?", params[:project_id])
310+
users = Project.find(params[:project_id]).default_users
310311
end
311-
users = @default_users ? @default_users : []
312312
users.reject! {|u| @task.users.include?(u) }
313313
res = render_to_string(:partial => "tasks/notification",:collection => users)
314314
render :text => res
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class LetTimestampsBeNilInDefaultProjectUsers < ActiveRecord::Migration
2+
3+
def change
4+
change_column :default_project_users, :created_at, :datetime, null: true
5+
change_column :default_project_users, :updated_at, :datetime, null: true
6+
end
7+
end

db/schema.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# It's strongly recommended to check this file into your version control system.
1313

14-
ActiveRecord::Schema.define(:version => 20150915045633) do
14+
ActiveRecord::Schema.define(:version => 20150926163831) do
1515

1616
create_table "access_levels", :force => true do |t|
1717
t.string "name"
@@ -92,8 +92,8 @@
9292
create_table "default_project_users", :force => true do |t|
9393
t.integer "project_id"
9494
t.integer "user_id"
95-
t.datetime "created_at", :null => false
96-
t.datetime "updated_at", :null => false
95+
t.datetime "created_at"
96+
t.datetime "updated_at"
9797
end
9898

9999
create_table "delayed_jobs", :force => true do |t|

test/blueprints.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,6 @@ def self.paragraphs(paragraph_count = 3)
131131
company { user.company }
132132
end
133133

134-
DefaultProjectUsers.blueprint do
135-
user_id
136-
project_id
137-
end
138-
139134
TaskFilterUser.blueprint do
140135
end
141136

test/functional/projects_controller_test.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,10 @@ class ProjectsControllerTest < ActionController::TestCase
5050
description: 'Some description',
5151
customer_id: @user.customer.id,
5252
company_id: @user.company.id,
53+
default_user_ids: [@user.id],
5354
}
54-
@d_users = [1,2]
55-
post :create, project: project_hash, copy_project_id: @project.id, default_users: @d_users
56-
users = DefaultProjectUsers.where(project_id: assigns[:project].id)
57-
assert_equal users.first.project_id, assigns[:project].id
55+
post :create, project: project_hash, copy_project_id: @project.id
56+
assert_equal [@user], assigns[:project].default_users
5857
end
5958

6059
should "get edit project page" do

test/functional/tasks_controller_test.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,7 @@ class << file
629629
setup do
630630
@task = @user.tasks.first
631631
@customer = @task.company.customers.first
632-
@project = @customer.projects.make(:company => @task.company)
633-
@default_user = DefaultProjectUsers.make(project_id: @project.id,user_id: @user.id)
632+
@project = @customer.projects.make(:company => @task.company, default_users: [@user])
634633
end
635634

636635
should "return auto add users for get_default_watchers_for_project" do

test/unit/default_project_users_test.rb

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)