Commit 0727edd8a0c68b640b95fabce21472b04a806562
1 parent
3fe9d297
Exists in
master
and in
4 other branches
Removed issues,mr delete buttons. Refactored models
Showing
13 changed files
with
82 additions
and
186 deletions
Show diff stats
app/controllers/merge_requests_controller.rb
@@ -30,7 +30,7 @@ class MergeRequestsController < ApplicationController | @@ -30,7 +30,7 @@ class MergeRequestsController < ApplicationController | ||
30 | else @merge_requests.opened | 30 | else @merge_requests.opened |
31 | end | 31 | end |
32 | 32 | ||
33 | - @merge_requests = @merge_requests.includes(:author, :project) | 33 | + @merge_requests = @merge_requests.includes(:author, :project).order("created_at desc") |
34 | end | 34 | end |
35 | 35 | ||
36 | def show | 36 | def show |
app/models/key.rb
@@ -14,8 +14,6 @@ class Key < ActiveRecord::Base | @@ -14,8 +14,6 @@ class Key < ActiveRecord::Base | ||
14 | 14 | ||
15 | before_save :set_identifier | 15 | before_save :set_identifier |
16 | before_validation :strip_white_space | 16 | before_validation :strip_white_space |
17 | - after_save :update_repository | ||
18 | - after_destroy :repository_delete_key | ||
19 | delegate :name, :email, :to => :user, :prefix => true | 17 | delegate :name, :email, :to => :user, :prefix => true |
20 | validate :unique_key | 18 | validate :unique_key |
21 | 19 |
app/models/project.rb
@@ -3,19 +3,17 @@ require "grit" | @@ -3,19 +3,17 @@ require "grit" | ||
3 | class Project < ActiveRecord::Base | 3 | class Project < ActiveRecord::Base |
4 | belongs_to :owner, :class_name => "User" | 4 | belongs_to :owner, :class_name => "User" |
5 | 5 | ||
6 | - has_many :events, :dependent => :destroy | 6 | + has_many :users, :through => :users_projects |
7 | + has_many :events, :dependent => :destroy | ||
7 | has_many :merge_requests, :dependent => :destroy | 8 | has_many :merge_requests, :dependent => :destroy |
8 | - has_many :issues, :dependent => :destroy, :order => "position" | 9 | + has_many :issues, :dependent => :destroy, :order => "position" |
9 | has_many :users_projects, :dependent => :destroy | 10 | has_many :users_projects, :dependent => :destroy |
10 | - has_many :users, :through => :users_projects | ||
11 | - has_many :notes, :dependent => :destroy | ||
12 | - has_many :snippets, :dependent => :destroy | ||
13 | - has_many :deploy_keys, :dependent => :destroy, :foreign_key => "project_id", :class_name => "Key" | ||
14 | - has_many :web_hooks, :dependent => :destroy | 11 | + has_many :notes, :dependent => :destroy |
12 | + has_many :snippets, :dependent => :destroy | ||
13 | + has_many :deploy_keys, :dependent => :destroy, :foreign_key => "project_id", :class_name => "Key" | ||
14 | + has_many :web_hooks, :dependent => :destroy | ||
15 | + has_many :wikis, :dependent => :destroy | ||
15 | has_many :protected_branches, :dependent => :destroy | 16 | has_many :protected_branches, :dependent => :destroy |
16 | - has_many :wikis, :dependent => :destroy | ||
17 | - | ||
18 | - acts_as_taggable | ||
19 | 17 | ||
20 | validates :name, | 18 | validates :name, |
21 | :uniqueness => true, | 19 | :uniqueness => true, |
@@ -39,15 +37,10 @@ class Project < ActiveRecord::Base | @@ -39,15 +37,10 @@ class Project < ActiveRecord::Base | ||
39 | :message => "only letters, digits & '_' '-' '.' allowed" }, | 37 | :message => "only letters, digits & '_' '-' '.' allowed" }, |
40 | :length => { :within => 3..255 } | 38 | :length => { :within => 3..255 } |
41 | 39 | ||
42 | - validates :owner, | ||
43 | - :presence => true | ||
44 | - | 40 | + validates :owner, :presence => true |
45 | validate :check_limit | 41 | validate :check_limit |
46 | validate :repo_name | 42 | validate :repo_name |
47 | 43 | ||
48 | - after_destroy :destroy_repository | ||
49 | - after_save :update_repository | ||
50 | - | ||
51 | attr_protected :private_flag, :owner_id | 44 | attr_protected :private_flag, :owner_id |
52 | 45 | ||
53 | scope :public_only, where(:private_flag => false) | 46 | scope :public_only, where(:private_flag => false) |
@@ -163,18 +156,6 @@ class Project < ActiveRecord::Base | @@ -163,18 +156,6 @@ class Project < ActiveRecord::Base | ||
163 | users_projects.find_by_user_id(user_id) | 156 | users_projects.find_by_user_id(user_id) |
164 | end | 157 | end |
165 | 158 | ||
166 | - def fresh_merge_requests(n) | ||
167 | - merge_requests.includes(:project, :author).order("created_at desc").first(n) | ||
168 | - end | ||
169 | - | ||
170 | - def fresh_issues(n) | ||
171 | - issues.includes(:project, :author).order("created_at desc").first(n) | ||
172 | - end | ||
173 | - | ||
174 | - def fresh_notes(n) | ||
175 | - notes.inc_author_project.order("created_at desc").first(n) | ||
176 | - end | ||
177 | - | ||
178 | def common_notes | 159 | def common_notes |
179 | notes.where(:noteable_type => ["", nil]).inc_author_project | 160 | notes.where(:noteable_type => ["", nil]).inc_author_project |
180 | end | 161 | end |
@@ -277,9 +258,7 @@ class Project < ActiveRecord::Base | @@ -277,9 +258,7 @@ class Project < ActiveRecord::Base | ||
277 | end | 258 | end |
278 | 259 | ||
279 | def last_activity | 260 | def last_activity |
280 | - events.last | ||
281 | - rescue | ||
282 | - nil | 261 | + events.last || nil |
283 | end | 262 | end |
284 | 263 | ||
285 | def last_activity_date | 264 | def last_activity_date |
@@ -294,43 +273,6 @@ class Project < ActiveRecord::Base | @@ -294,43 +273,6 @@ class Project < ActiveRecord::Base | ||
294 | last_activity_date | 273 | last_activity_date |
295 | end | 274 | end |
296 | 275 | ||
297 | - # Get project updates from cache | ||
298 | - # or calculate. | ||
299 | - def cached_updates(limit, expire = 2.minutes) | ||
300 | - activities_key = "project_#{id}_activities" | ||
301 | - cached_activities = Rails.cache.read(activities_key) | ||
302 | - if cached_activities | ||
303 | - activities = cached_activities | ||
304 | - else | ||
305 | - activities = updates(limit) | ||
306 | - Rails.cache.write(activities_key, activities, :expires_in => expire) | ||
307 | - end | ||
308 | - | ||
309 | - activities | ||
310 | - end | ||
311 | - | ||
312 | - # Get 20 events for project like | ||
313 | - # commits, issues or notes | ||
314 | - def updates(n = 3) | ||
315 | - [ | ||
316 | - fresh_commits(n), | ||
317 | - fresh_issues(n), | ||
318 | - fresh_notes(n) | ||
319 | - ].compact.flatten.sort do |x, y| | ||
320 | - y.created_at <=> x.created_at | ||
321 | - end[0...n] | ||
322 | - end | ||
323 | - | ||
324 | - def activities(n=3) | ||
325 | - [ | ||
326 | - fresh_issues(n), | ||
327 | - fresh_merge_requests(n), | ||
328 | - notes.inc_author_project.where("noteable_type is not null").order("created_at desc").first(n) | ||
329 | - ].compact.flatten.sort do |x, y| | ||
330 | - y.created_at <=> x.created_at | ||
331 | - end[0...n] | ||
332 | - end | ||
333 | - | ||
334 | def check_limit | 276 | def check_limit |
335 | unless owner.can_create_project? | 277 | unless owner.can_create_project? |
336 | errors[:base] << ("Your own projects limit is #{owner.projects_limit}! Please contact administrator to increase it") | 278 | errors[:base] << ("Your own projects limit is #{owner.projects_limit}! Please contact administrator to increase it") |
app/views/issues/_form.html.haml
@@ -9,6 +9,10 @@ | @@ -9,6 +9,10 @@ | ||
9 | %li= msg | 9 | %li= msg |
10 | 10 | ||
11 | .clearfix | 11 | .clearfix |
12 | + = f.label :title | ||
13 | + .input= f.text_area :title, :maxlength => 255, :class => "xxlarge" | ||
14 | + | ||
15 | + .clearfix | ||
12 | = f.label :assignee_id | 16 | = f.label :assignee_id |
13 | .input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" }) | 17 | .input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" }) |
14 | 18 | ||
@@ -21,9 +25,6 @@ | @@ -21,9 +25,6 @@ | ||
21 | = f.label :closed | 25 | = f.label :closed |
22 | .input= f.check_box :closed | 26 | .input= f.check_box :closed |
23 | 27 | ||
24 | - .clearfix | ||
25 | - = f.label :title | ||
26 | - .input= f.text_area :title, :maxlength => 255, :class => "xxlarge" | ||
27 | .actions | 28 | .actions |
28 | = f.submit 'Save', :class => "primary btn" | 29 | = f.submit 'Save', :class => "primary btn" |
29 | 30 | ||
@@ -34,8 +35,3 @@ | @@ -34,8 +35,3 @@ | ||
34 | = link_to "Cancel", project_issues_path(@project), :class => "btn" | 35 | = link_to "Cancel", project_issues_path(@project), :class => "btn" |
35 | - else | 36 | - else |
36 | = link_to "Cancel", project_issue_path(@project, @issue), :class => "btn" | 37 | = link_to "Cancel", project_issue_path(@project, @issue), :class => "btn" |
37 | - | ||
38 | - | ||
39 | - - unless @issue.new_record? | ||
40 | - .right | ||
41 | - = link_to 'Remove', [@project, @issue], :confirm => 'Are you sure?', :method => :delete, :class => "danger btn" |
app/views/issues/_show.html.haml
@@ -6,8 +6,6 @@ | @@ -6,8 +6,6 @@ | ||
6 | - else | 6 | - else |
7 | = link_to 'Resolve', project_issue_path(issue.project, issue, :issue => {:closed => true }, :status_only => true), :method => :put, :class => "success btn small", :remote => true | 7 | = link_to 'Resolve', project_issue_path(issue.project, issue, :issue => {:closed => true }, :status_only => true), :method => :put, :class => "success btn small", :remote => true |
8 | = link_to 'Edit', edit_project_issue_path(issue.project, issue), :class => "btn small edit-issue-link", :remote => true | 8 | = link_to 'Edit', edit_project_issue_path(issue.project, issue), :class => "btn small edit-issue-link", :remote => true |
9 | - -#- if can?(current_user, :admin_issue, @project) || issue.author == current_user | ||
10 | - = link_to 'Remove', [issue.project, issue], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "danger btn small delete-issue", :id => "destroy_issue_#{issue.id}" | ||
11 | = image_tag gravatar_icon(issue.assignee_email), :class => "avatar" | 9 | = image_tag gravatar_icon(issue.assignee_email), :class => "avatar" |
12 | %span.update-author | 10 | %span.update-author |
13 | assigned to | 11 | assigned to |
app/views/merge_requests/_form.html.haml
@@ -6,6 +6,9 @@ | @@ -6,6 +6,9 @@ | ||
6 | %li= msg | 6 | %li= msg |
7 | 7 | ||
8 | .clearfix | 8 | .clearfix |
9 | + = f.label :title | ||
10 | + .input= f.text_area :title, :class => "xxlarge", :maxlength => 255, :rows => 5 | ||
11 | + .clearfix | ||
9 | = f.label :source_branch, "From" | 12 | = f.label :source_branch, "From" |
10 | .input= f.select(:source_branch, @project.heads.map(&:name), { :include_blank => "Select branch" }, :style => "width:250px") | 13 | .input= f.select(:source_branch, @project.heads.map(&:name), { :include_blank => "Select branch" }, :style => "width:250px") |
11 | .clearfix | 14 | .clearfix |
@@ -15,9 +18,6 @@ | @@ -15,9 +18,6 @@ | ||
15 | = f.label :assignee_id, "Assign to" | 18 | = f.label :assignee_id, "Assign to" |
16 | .input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" }, :style => "width:250px") | 19 | .input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" }, :style => "width:250px") |
17 | 20 | ||
18 | - .clearfix | ||
19 | - = f.label :title | ||
20 | - .input= f.text_area :title, :class => "xlarge", :maxlength => 255, :rows => 5 | ||
21 | .actions | 21 | .actions |
22 | = f.submit 'Save', :class => "primary btn" | 22 | = f.submit 'Save', :class => "primary btn" |
23 | - if @merge_request.new_record? | 23 | - if @merge_request.new_record? |
@@ -26,11 +26,6 @@ | @@ -26,11 +26,6 @@ | ||
26 | - else | 26 | - else |
27 | = link_to project_merge_request_path(@project, @merge_request), :class => "btn" do | 27 | = link_to project_merge_request_path(@project, @merge_request), :class => "btn" do |
28 | Cancel | 28 | Cancel |
29 | - | ||
30 | - - unless @merge_request.new_record? | ||
31 | - .right | ||
32 | - = link_to 'Remove', [@project, @merge_request], :confirm => 'Are you sure?', :method => :delete, :class => "btn danger" | ||
33 | - | ||
34 | 29 | ||
35 | 30 | ||
36 | 31 |
app/views/projects/index.html.haml
1 | -- unless @projects.empty? | ||
2 | - .row | ||
3 | - .span4 | ||
4 | - %div.leftbar.ui-box | ||
5 | - %h5 | ||
6 | - Projects | ||
7 | - - if current_user.can_create_project? | ||
8 | - %span.right | ||
9 | - = link_to new_project_path, :class => "btn very_small info" do | ||
10 | - New Project | ||
11 | - .content_list | ||
12 | - - @projects.each do |project| | ||
13 | - = link_to project_path(project), :remote => true, :class => dom_class(project) do | ||
14 | - %h4 | ||
15 | - %span.ico.project | ||
16 | - = truncate(project.name, :length => 22) | ||
17 | - .span12.right | ||
18 | - .show_holder.ui-box.padded | ||
19 | - .loading | ||
20 | - | ||
21 | -- else | ||
22 | - %h2 Nothing here | 1 | +.row |
2 | + .span4 | ||
3 | + %div.leftbar.ui-box | ||
4 | + %h5 | ||
5 | + Projects | ||
6 | + - if current_user.can_create_project? | ||
7 | + %span.right | ||
8 | + = link_to new_project_path, :class => "btn very_small info" do | ||
9 | + New Project | ||
10 | + .content_list | ||
11 | + - @projects.each do |project| | ||
12 | + = link_to project_path(project), :remote => true, :class => dom_class(project) do | ||
13 | + %h4 | ||
14 | + %span.ico.project | ||
15 | + = truncate(project.name, :length => 22) | ||
16 | + .span12.right | ||
17 | + .show_holder.ui-box.padded | ||
18 | + .loading | ||
23 | 19 | ||
24 | 20 | ||
25 | :javascript | 21 | :javascript |
config/application.rb
@@ -23,7 +23,7 @@ module Gitlab | @@ -23,7 +23,7 @@ module Gitlab | ||
23 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ] | 23 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ] |
24 | 24 | ||
25 | # Activate observers that should always be running. | 25 | # Activate observers that should always be running. |
26 | - config.active_record.observers = :mailer_observer, :activity_observer | 26 | + config.active_record.observers = :mailer_observer, :activity_observer, :project_observer, :key_observer |
27 | 27 | ||
28 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. | 28 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. |
29 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. | 29 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. |
db/schema.rb
@@ -24,25 +24,13 @@ ActiveRecord::Schema.define(:version => 20120301185805) do | @@ -24,25 +24,13 @@ ActiveRecord::Schema.define(:version => 20120301185805) do | ||
24 | t.integer "action" | 24 | t.integer "action" |
25 | end | 25 | end |
26 | 26 | ||
27 | - create_table "features", :force => true do |t| | ||
28 | - t.string "name" | ||
29 | - t.string "branch_name" | ||
30 | - t.integer "assignee_id" | ||
31 | - t.integer "author_id" | ||
32 | - t.integer "project_id" | ||
33 | - t.datetime "created_at" | ||
34 | - t.datetime "updated_at" | ||
35 | - t.string "version" | ||
36 | - t.integer "status", :default => 0, :null => false | ||
37 | - end | ||
38 | - | ||
39 | create_table "issues", :force => true do |t| | 27 | create_table "issues", :force => true do |t| |
40 | t.string "title" | 28 | t.string "title" |
41 | t.integer "assignee_id" | 29 | t.integer "assignee_id" |
42 | t.integer "author_id" | 30 | t.integer "author_id" |
43 | t.integer "project_id" | 31 | t.integer "project_id" |
44 | - t.datetime "created_at" | ||
45 | - t.datetime "updated_at" | 32 | + t.datetime "created_at", :null => false |
33 | + t.datetime "updated_at", :null => false | ||
46 | t.boolean "closed", :default => false, :null => false | 34 | t.boolean "closed", :default => false, :null => false |
47 | t.integer "position", :default => 0 | 35 | t.integer "position", :default => 0 |
48 | t.boolean "critical", :default => false, :null => false | 36 | t.boolean "critical", :default => false, :null => false |
@@ -53,8 +41,8 @@ ActiveRecord::Schema.define(:version => 20120301185805) do | @@ -53,8 +41,8 @@ ActiveRecord::Schema.define(:version => 20120301185805) do | ||
53 | 41 | ||
54 | create_table "keys", :force => true do |t| | 42 | create_table "keys", :force => true do |t| |
55 | t.integer "user_id" | 43 | t.integer "user_id" |
56 | - t.datetime "created_at" | ||
57 | - t.datetime "updated_at" | 44 | + t.datetime "created_at", :null => false |
45 | + t.datetime "updated_at", :null => false | ||
58 | t.text "key" | 46 | t.text "key" |
59 | t.string "title" | 47 | t.string "title" |
60 | t.string "identifier" | 48 | t.string "identifier" |
@@ -69,8 +57,8 @@ ActiveRecord::Schema.define(:version => 20120301185805) do | @@ -69,8 +57,8 @@ ActiveRecord::Schema.define(:version => 20120301185805) do | ||
69 | t.integer "assignee_id" | 57 | t.integer "assignee_id" |
70 | t.string "title" | 58 | t.string "title" |
71 | t.boolean "closed", :default => false, :null => false | 59 | t.boolean "closed", :default => false, :null => false |
72 | - t.datetime "created_at" | ||
73 | - t.datetime "updated_at" | 60 | + t.datetime "created_at", :null => false |
61 | + t.datetime "updated_at", :null => false | ||
74 | end | 62 | end |
75 | 63 | ||
76 | add_index "merge_requests", ["project_id"], :name => "index_merge_requests_on_project_id" | 64 | add_index "merge_requests", ["project_id"], :name => "index_merge_requests_on_project_id" |
@@ -80,8 +68,8 @@ ActiveRecord::Schema.define(:version => 20120301185805) do | @@ -80,8 +68,8 @@ ActiveRecord::Schema.define(:version => 20120301185805) do | ||
80 | t.string "noteable_id" | 68 | t.string "noteable_id" |
81 | t.string "noteable_type" | 69 | t.string "noteable_type" |
82 | t.integer "author_id" | 70 | t.integer "author_id" |
83 | - t.datetime "created_at" | ||
84 | - t.datetime "updated_at" | 71 | + t.datetime "created_at", :null => false |
72 | + t.datetime "updated_at", :null => false | ||
85 | t.integer "project_id" | 73 | t.integer "project_id" |
86 | t.string "attachment" | 74 | t.string "attachment" |
87 | t.string "line_code" | 75 | t.string "line_code" |
@@ -94,8 +82,8 @@ ActiveRecord::Schema.define(:version => 20120301185805) do | @@ -94,8 +82,8 @@ ActiveRecord::Schema.define(:version => 20120301185805) do | ||
94 | t.string "name" | 82 | t.string "name" |
95 | t.string "path" | 83 | t.string "path" |
96 | t.text "description" | 84 | t.text "description" |
97 | - t.datetime "created_at" | ||
98 | - t.datetime "updated_at" | 85 | + t.datetime "created_at", :null => false |
86 | + t.datetime "updated_at", :null => false | ||
99 | t.boolean "private_flag", :default => true, :null => false | 87 | t.boolean "private_flag", :default => true, :null => false |
100 | t.string "code" | 88 | t.string "code" |
101 | t.integer "owner_id" | 89 | t.integer "owner_id" |
@@ -118,8 +106,8 @@ ActiveRecord::Schema.define(:version => 20120301185805) do | @@ -118,8 +106,8 @@ ActiveRecord::Schema.define(:version => 20120301185805) do | ||
118 | t.text "content" | 106 | t.text "content" |
119 | t.integer "author_id", :null => false | 107 | t.integer "author_id", :null => false |
120 | t.integer "project_id", :null => false | 108 | t.integer "project_id", :null => false |
121 | - t.datetime "created_at" | ||
122 | - t.datetime "updated_at" | 109 | + t.datetime "created_at", :null => false |
110 | + t.datetime "updated_at", :null => false | ||
123 | t.string "file_name" | 111 | t.string "file_name" |
124 | t.datetime "expires_at" | 112 | t.datetime "expires_at" |
125 | end | 113 | end |
@@ -152,8 +140,8 @@ ActiveRecord::Schema.define(:version => 20120301185805) do | @@ -152,8 +140,8 @@ ActiveRecord::Schema.define(:version => 20120301185805) do | ||
152 | t.datetime "last_sign_in_at" | 140 | t.datetime "last_sign_in_at" |
153 | t.string "current_sign_in_ip" | 141 | t.string "current_sign_in_ip" |
154 | t.string "last_sign_in_ip" | 142 | t.string "last_sign_in_ip" |
155 | - t.datetime "created_at" | ||
156 | - t.datetime "updated_at" | 143 | + t.datetime "created_at", :null => false |
144 | + t.datetime "updated_at", :null => false | ||
157 | t.string "name" | 145 | t.string "name" |
158 | t.boolean "admin", :default => false, :null => false | 146 | t.boolean "admin", :default => false, :null => false |
159 | t.integer "projects_limit", :default => 10 | 147 | t.integer "projects_limit", :default => 10 |
@@ -171,16 +159,16 @@ ActiveRecord::Schema.define(:version => 20120301185805) do | @@ -171,16 +159,16 @@ ActiveRecord::Schema.define(:version => 20120301185805) do | ||
171 | create_table "users_projects", :force => true do |t| | 159 | create_table "users_projects", :force => true do |t| |
172 | t.integer "user_id", :null => false | 160 | t.integer "user_id", :null => false |
173 | t.integer "project_id", :null => false | 161 | t.integer "project_id", :null => false |
174 | - t.datetime "created_at" | ||
175 | - t.datetime "updated_at" | 162 | + t.datetime "created_at", :null => false |
163 | + t.datetime "updated_at", :null => false | ||
176 | t.integer "project_access", :default => 0, :null => false | 164 | t.integer "project_access", :default => 0, :null => false |
177 | end | 165 | end |
178 | 166 | ||
179 | create_table "web_hooks", :force => true do |t| | 167 | create_table "web_hooks", :force => true do |t| |
180 | t.string "url" | 168 | t.string "url" |
181 | t.integer "project_id" | 169 | t.integer "project_id" |
182 | - t.datetime "created_at" | ||
183 | - t.datetime "updated_at" | 170 | + t.datetime "created_at", :null => false |
171 | + t.datetime "updated_at", :null => false | ||
184 | end | 172 | end |
185 | 173 | ||
186 | create_table "wikis", :force => true do |t| | 174 | create_table "wikis", :force => true do |t| |
spec/models/project_spec.rb
@@ -2,13 +2,17 @@ require 'spec_helper' | @@ -2,13 +2,17 @@ require 'spec_helper' | ||
2 | 2 | ||
3 | describe Project do | 3 | describe Project do |
4 | describe "Associations" do | 4 | describe "Associations" do |
5 | - it { should have_many(:events) } | ||
6 | it { should have_many(:users) } | 5 | it { should have_many(:users) } |
7 | - it { should have_many(:users_projects) } | ||
8 | - it { should have_many(:issues) } | ||
9 | - it { should have_many(:notes) } | ||
10 | - it { should have_many(:snippets) } | 6 | + it { should have_many(:protected_branches).dependent(:destroy) } |
7 | + it { should have_many(:events).dependent(:destroy) } | ||
8 | + it { should have_many(:wikis).dependent(:destroy) } | ||
9 | + it { should have_many(:merge_requests).dependent(:destroy) } | ||
10 | + it { should have_many(:users_projects).dependent(:destroy) } | ||
11 | + it { should have_many(:issues).dependent(:destroy) } | ||
12 | + it { should have_many(:notes).dependent(:destroy) } | ||
13 | + it { should have_many(:snippets).dependent(:destroy) } | ||
11 | it { should have_many(:web_hooks).dependent(:destroy) } | 14 | it { should have_many(:web_hooks).dependent(:destroy) } |
15 | + it { should have_many(:deploy_keys).dependent(:destroy) } | ||
12 | end | 16 | end |
13 | 17 | ||
14 | describe "Validation" do | 18 | describe "Validation" do |
@@ -70,30 +74,6 @@ describe Project do | @@ -70,30 +74,6 @@ describe Project do | ||
70 | end | 74 | end |
71 | end | 75 | end |
72 | 76 | ||
73 | - describe "updates" do | ||
74 | - let(:project) { Factory :project } | ||
75 | - | ||
76 | - before do | ||
77 | - @issue = Factory :issue, | ||
78 | - :project => project, | ||
79 | - :author => Factory(:user), | ||
80 | - :assignee => Factory(:user) | ||
81 | - | ||
82 | - @note = Factory :note, | ||
83 | - :project => project, | ||
84 | - :author => Factory(:user) | ||
85 | - | ||
86 | - @commit = project.fresh_commits(1).first | ||
87 | - end | ||
88 | - | ||
89 | - describe "return commit, note & issue" do | ||
90 | - it { project.updates(3).count.should == 3 } | ||
91 | - it { project.updates(3).last.id.should == @commit.id } | ||
92 | - it { project.updates(3).include?(@issue).should be_true } | ||
93 | - it { project.updates(3).include?(@note).should be_true } | ||
94 | - end | ||
95 | - end | ||
96 | - | ||
97 | describe "last_activity" do | 77 | describe "last_activity" do |
98 | let(:project) { Factory :project } | 78 | let(:project) { Factory :project } |
99 | 79 |
spec/requests/issues_spec.rb
@@ -46,21 +46,6 @@ describe "Issues" do | @@ -46,21 +46,6 @@ describe "Issues" do | ||
46 | page.body.should have_selector("entry summary", :text => @issue.title) | 46 | page.body.should have_selector("entry summary", :text => @issue.title) |
47 | end | 47 | end |
48 | 48 | ||
49 | - describe "Destroy" do | ||
50 | - before do | ||
51 | - # admin access to remove issue | ||
52 | - @user.users_projects.destroy_all | ||
53 | - project.add_access(@user, :read, :write, :admin) | ||
54 | - visit edit_project_issue_path(project, @issue) | ||
55 | - end | ||
56 | - | ||
57 | - it "should remove entry" do | ||
58 | - expect { | ||
59 | - click_link "Remove" | ||
60 | - }.to change { Issue.count }.by(-1) | ||
61 | - end | ||
62 | - end | ||
63 | - | ||
64 | describe "statuses" do | 49 | describe "statuses" do |
65 | before do | 50 | before do |
66 | @closed_issue = Factory :issue, | 51 | @closed_issue = Factory :issue, |