Commit d89527839ea0dd1734dacb71c3ed2a97f1ff74d7

Authored by skv
1 parent ee53b739

fix most of warnings

app/controllers/admin/projects_controller.rb
... ... @@ -7,7 +7,7 @@ class Admin::ProjectsController < Admin::ApplicationController
7 7 owner_id = params[:owner_id]
8 8 user = User.find_by_id(owner_id)
9 9  
10   - @projects = user ? user.owned_projects : Project.scoped
  10 + @projects = user ? user.owned_projects : Project.all
11 11 @projects = @projects.where("visibility_level IN (?)", params[:visibility_levels]) if params[:visibility_levels].present?
12 12 @projects = @projects.with_push if params[:with_push].present?
13 13 @projects = @projects.abandoned if params[:abandoned].present?
... ...
app/controllers/admin/users_controller.rb
... ... @@ -2,8 +2,7 @@ class Admin::UsersController < Admin::ApplicationController
2 2 before_filter :user, only: [:show, :edit, :update, :destroy]
3 3  
4 4 def index
5   - @users = User.scoped
6   - @users = @users.filter(params[:filter])
  5 + @users = User.filter(params[:filter])
7 6 @users = @users.search(params[:name]) if params[:name].present?
8 7 @users = @users.alphabetically.page(params[:page])
9 8 end
... ...
app/controllers/profiles/keys_controller.rb
... ... @@ -2,7 +2,7 @@ class Profiles::KeysController < ApplicationController
2 2 layout "profile"
3 3  
4 4 def index
5   - @keys = current_user.keys.order('id DESC').all
  5 + @keys = current_user.keys.order('id DESC')
6 6 end
7 7  
8 8 def show
... ...
app/controllers/projects/deploy_keys_controller.rb
... ... @@ -7,7 +7,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
7 7 layout "project_settings"
8 8  
9 9 def index
10   - @enabled_keys = @project.deploy_keys.all
  10 + @enabled_keys = @project.deploy_keys
11 11 @available_keys = available_keys - @enabled_keys
12 12 end
13 13  
... ...
app/controllers/projects/hooks_controller.rb
... ... @@ -7,7 +7,7 @@ class Projects::HooksController < Projects::ApplicationController
7 7 layout "project_settings"
8 8  
9 9 def index
10   - @hooks = @project.hooks.all
  10 + @hooks = @project.hooks
11 11 @hook = ProjectHook.new
12 12 end
13 13  
... ... @@ -18,7 +18,7 @@ class Projects::HooksController < Projects::ApplicationController
18 18 if @hook.valid?
19 19 redirect_to project_hooks_path(@project)
20 20 else
21   - @hooks = @project.hooks.all
  21 + @hooks = @project.hooks
22 22 render :index
23 23 end
24 24 end
... ...
app/models/project.rb
... ... @@ -322,14 +322,14 @@ class Project < ActiveRecord::Base
322 322 c_ids = self.repository.commits_between(oldrev, newrev).map(&:id)
323 323  
324 324 # Update code for merge requests into project between project branches
325   - mrs = self.merge_requests.opened.by_branch(branch_name).all
  325 + mrs = self.merge_requests.opened.by_branch(branch_name).to_a
326 326 # Update code for merge requests between project and project fork
327   - mrs += self.fork_merge_requests.opened.by_branch(branch_name).all
  327 + mrs += self.fork_merge_requests.opened.by_branch(branch_name).to_a
328 328  
329 329 mrs.each { |merge_request| merge_request.reload_code; merge_request.mark_as_unchecked }
330 330  
331 331 # Close merge requests
332   - mrs = self.merge_requests.opened.where(target_branch: branch_name).all
  332 + mrs = self.merge_requests.opened.where(target_branch: branch_name).to_a
333 333 mrs = mrs.select(&:last_commit).select { |mr| c_ids.include?(mr.last_commit.id) }
334 334 mrs.each { |merge_request| merge_request.merge!(user.id) }
335 335  
... ...
app/models/project_team.rb
... ... @@ -87,8 +87,8 @@ class ProjectTeam
87 87 def import(source_project)
88 88 target_project = project
89 89  
90   - source_team = source_project.users_projects.all
91   - target_team = target_project.users_projects.all
  90 + source_team = source_project.users_projects.to_a
  91 + target_team = target_project.users_projects.to_a
92 92 target_user_ids = target_team.map(&:user_id)
93 93  
94 94 source_team.reject! do |tm|
... ...
app/models/user.rb
... ... @@ -163,7 +163,7 @@ class User < ActiveRecord::Base
163 163 scope :alphabetically, -> { order('name ASC') }
164 164 scope :in_team, ->(team){ where(id: team.member_ids) }
165 165 scope :not_in_team, ->(team){ where('users.id NOT IN (:ids)', ids: team.member_ids) }
166   - scope :not_in_project, ->(project) { project.users.present? ? where("id not in (:ids)", ids: project.users.map(&:id) ) : scoped }
  166 + scope :not_in_project, ->(project) { project.users.present? ? where("id not in (:ids)", ids: project.users.map(&:id) ) : all }
167 167 scope :without_projects, -> { where('id NOT IN (SELECT DISTINCT(user_id) FROM users_projects)') }
168 168 scope :ldap, -> { where(provider: 'ldap') }
169 169  
... ...
app/views/projects/issues/_form.html.haml
... ... @@ -29,7 +29,7 @@
29 29 = f.label :milestone_id do
30 30 %i.icon-time
31 31 Milestone
32   - .controls= f.select(:milestone_id, @project.milestones.active.all.collect {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'})
  32 + .controls= f.select(:milestone_id, @project.milestones.active.collect {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'})
33 33  
34 34 .ui-box-bottom
35 35 .control-group
... ...
app/views/projects/merge_requests/_form.html.haml
... ... @@ -44,7 +44,7 @@
44 44 = f.label :milestone_id do
45 45 %i.icon-time
46 46 Milestone
47   - .controls= f.select(:milestone_id, @project.milestones.active.all.map {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'})
  47 + .controls= f.select(:milestone_id, @project.milestones.active.map {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'})
48 48 .control-group
49 49 = f.label :description, "Description"
50 50 .controls
... ...
lib/api/namespaces.rb
... ... @@ -12,7 +12,7 @@ module API
12 12 # Example Request:
13 13 # GET /namespaces
14 14 get do
15   - @namespaces = Namespace.scoped
  15 + @namespaces = Namespace.all
16 16 @namespaces = @namespaces.search(params[:search]) if params[:search].present?
17 17 @namespaces = paginate @namespaces
18 18  
... ...
lib/api/users.rb
... ... @@ -9,7 +9,7 @@ module API
9 9 # Example Request:
10 10 # GET /users
11 11 get do
12   - @users = User.scoped
  12 + @users = User.all
13 13 @users = @users.active if params[:active].present?
14 14 @users = @users.search(params[:search]) if params[:search].present?
15 15 @users = paginate @users
... ...
spec/contexts/fork_context_spec.rb
... ... @@ -48,7 +48,7 @@ describe Projects::ForkContext do
48 48  
49 49 def fork_project(from_project, user, fork_success = true)
50 50 context = Projects::ForkContext.new(from_project, user)
51   - shell = mock("gitlab_shell")
  51 + shell = double("gitlab_shell")
52 52 shell.stub(fork_repository: fork_success)
53 53 context.stub(gitlab_shell: shell)
54 54 context.execute
... ...
spec/controllers/application_controller_spec.rb
... ... @@ -8,7 +8,7 @@ describe ApplicationController do
8 8 it 'should redirect if the user is over their password expiry' do
9 9 user.password_expires_at = Time.new(2002)
10 10 user.ldap_user?.should be_false
11   - controller.stub!(:current_user).and_return(user)
  11 + controller.stub(:current_user).and_return(user)
12 12 controller.should_receive(:redirect_to)
13 13 controller.should_receive(:new_profile_password_path)
14 14 controller.send(:check_password_expiration)
... ... @@ -17,15 +17,15 @@ describe ApplicationController do
17 17 it 'should not redirect if the user is under their password expiry' do
18 18 user.password_expires_at = Time.now + 20010101
19 19 user.ldap_user?.should be_false
20   - controller.stub!(:current_user).and_return(user)
  20 + controller.stub(:current_user).and_return(user)
21 21 controller.should_not_receive(:redirect_to)
22 22 controller.send(:check_password_expiration)
23 23 end
24 24  
25 25 it 'should not redirect if the user is over their password expiry but they are an ldap user' do
26 26 user.password_expires_at = Time.new(2002)
27   - user.stub!(:ldap_user?).and_return(true)
28   - controller.stub!(:current_user).and_return(user)
  27 + user.stub(:ldap_user?).and_return(true)
  28 + controller.stub(:current_user).and_return(user)
29 29 controller.should_not_receive(:redirect_to)
30 30 controller.send(:check_password_expiration)
31 31 end
... ...
spec/helpers/application_helper_spec.rb
... ... @@ -3,7 +3,7 @@ require 'spec_helper'
3 3 describe ApplicationHelper do
4 4 describe 'current_controller?' do
5 5 before do
6   - controller.stub!(:controller_name).and_return('foo')
  6 + controller.stub(:controller_name).and_return('foo')
7 7 end
8 8  
9 9 it "returns true when controller matches argument" do
... ... @@ -22,7 +22,7 @@ describe ApplicationHelper do
22 22  
23 23 describe 'current_action?' do
24 24 before do
25   - stub!(:action_name).and_return('foo')
  25 + allow(self).to receive(:action_name).and_return('foo')
26 26 end
27 27  
28 28 it "returns true when action matches argument" do
... ... @@ -52,7 +52,7 @@ describe ApplicationHelper do
52 52 it "should call gravatar_icon when no avatar is present" do
53 53 user = create(:user)
54 54 user.save!
55   - stub!(:gravatar_icon).and_return('gravatar_method_called')
  55 + allow(self).to receive(:gravatar_icon).and_return('gravatar_method_called')
56 56 avatar_icon(user.email).to_s.should == "gravatar_method_called"
57 57 end
58 58 end
... ... @@ -70,33 +70,33 @@ describe ApplicationHelper do
70 70 end
71 71  
72 72 it "should return default gravatar url" do
73   - stub!(:request).and_return(double(:ssl? => false))
  73 + allow(self).to receive(:request).and_return(double(:ssl? => false))
74 74 gravatar_icon(user_email).should match('http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118')
75 75 end
76 76  
77 77 it "should use SSL when appropriate" do
78   - stub!(:request).and_return(double(:ssl? => true))
  78 + allow(self).to receive(:request).and_return(double(:ssl? => true))
79 79 gravatar_icon(user_email).should match('https://secure.gravatar.com')
80 80 end
81 81  
82 82 it "should return custom gravatar path when gravatar_url is set" do
83   - stub!(:request).and_return(double(:ssl? => false))
  83 + allow(self).to receive(:request).and_return(double(:ssl? => false))
84 84 Gitlab.config.gravatar.stub(:plain_url).and_return('http://example.local/?s=%{size}&hash=%{hash}')
85 85 gravatar_icon(user_email, 20).should == 'http://example.local/?s=20&hash=b58c6f14d292556214bd64909bcdb118'
86 86 end
87 87  
88 88 it "should accept a custom size" do
89   - stub!(:request).and_return(double(:ssl? => false))
  89 + allow(self).to receive(:request).and_return(double(:ssl? => false))
90 90 gravatar_icon(user_email, 64).should match(/\?s=64/)
91 91 end
92 92  
93 93 it "should use default size when size is wrong" do
94   - stub!(:request).and_return(double(:ssl? => false))
  94 + allow(self).to receive(:request).and_return(double(:ssl? => false))
95 95 gravatar_icon(user_email, nil).should match(/\?s=40/)
96 96 end
97 97  
98 98 it "should be case insensitive" do
99   - stub!(:request).and_return(double(:ssl? => false))
  99 + allow(self).to receive(:request).and_return(double(:ssl? => false))
100 100 gravatar_icon(user_email).should == gravatar_icon(user_email.upcase + " ")
101 101 end
102 102  
... ... @@ -105,7 +105,7 @@ describe ApplicationHelper do
105 105 describe "user_color_scheme_class" do
106 106 context "with current_user is nil" do
107 107 it "should return a string" do
108   - stub!(:current_user).and_return(nil)
  108 + allow(self).to receive(:current_user).and_return(nil)
109 109 user_color_scheme_class.should be_kind_of(String)
110 110 end
111 111 end
... ... @@ -115,7 +115,7 @@ describe ApplicationHelper do
115 115 context "with color_scheme_id == #{color_scheme_id}" do
116 116 it "should return a string" do
117 117 current_user = double(:color_scheme_id => color_scheme_id)
118   - stub!(:current_user).and_return(current_user)
  118 + allow(self).to receive(:current_user).and_return(current_user)
119 119 user_color_scheme_class.should be_kind_of(String)
120 120 end
121 121 end
... ...
spec/helpers/gitlab_markdown_helper_spec.rb
... ... @@ -435,7 +435,7 @@ describe GitlabMarkdownHelper do
435 435  
436 436 describe "#render_wiki_content" do
437 437 before do
438   - @wiki = stub('WikiPage')
  438 + @wiki = double('WikiPage')
439 439 @wiki.stub(:content).and_return('wiki content')
440 440 end
441 441  
... ... @@ -449,7 +449,7 @@ describe GitlabMarkdownHelper do
449 449  
450 450 it "should use the Gollum renderer for all other file types" do
451 451 @wiki.stub(:format).and_return(:rdoc)
452   - formatted_content_stub = stub('formatted_content')
  452 + formatted_content_stub = double('formatted_content')
453 453 formatted_content_stub.should_receive(:html_safe)
454 454 @wiki.stub(:formatted_content).and_return(formatted_content_stub)
455 455  
... ...
spec/helpers/notifications_helper_spec.rb
... ... @@ -2,7 +2,7 @@ require 'spec_helper'
2 2  
3 3 describe NotificationsHelper do
4 4 describe 'notification_icon' do
5   - let(:notification) { stub(disabled?: false, participating?: false, watch?: false) }
  5 + let(:notification) { double(disabled?: false, participating?: false, watch?: false) }
6 6  
7 7 context "disabled notification" do
8 8 before { notification.stub(disabled?: true) }
... ...
spec/helpers/search_helper_spec.rb
... ... @@ -8,7 +8,9 @@ describe SearchHelper do
8 8  
9 9 describe 'search_autocomplete_source' do
10 10 context "with no current user" do
11   - before { stub!(:current_user).and_return(nil) }
  11 + before do
  12 + allow(self).to receive(:current_user).and_return(nil)
  13 + end
12 14  
13 15 it "it returns nil" do
14 16 search_autocomplete_source.should be_nil
... ... @@ -20,7 +22,7 @@ describe SearchHelper do
20 22 let(:result) { JSON.parse(search_autocomplete_source) }
21 23  
22 24 before do
23   - stub!(:current_user).and_return(user)
  25 + allow(self).to receive(:current_user).and_return(user)
24 26 end
25 27  
26 28 it "includes Help sections" do
... ...
spec/helpers/tab_helper_spec.rb
... ... @@ -5,8 +5,8 @@ describe TabHelper do
5 5  
6 6 describe 'nav_link' do
7 7 before do
8   - controller.stub!(:controller_name).and_return('foo')
9   - stub!(:action_name).and_return('foo')
  8 + controller.stub(:controller_name).and_return('foo')
  9 + allow(self).to receive(:action_name).and_return('foo')
10 10 end
11 11  
12 12 it "captures block output" do
... ...
spec/lib/extracts_path_spec.rb
... ... @@ -7,7 +7,7 @@ describe ExtractsPath do
7 7  
8 8 before do
9 9 @project = project
10   - project.stub(repository: stub(ref_names: ['master', 'foo/bar/baz', 'v1.0.0', 'v2.0.0']))
  10 + project.stub(repository: double(ref_names: ['master', 'foo/bar/baz', 'v1.0.0', 'v2.0.0']))
11 11 project.stub(path_with_namespace: 'gitlab/gitlab-ci')
12 12 end
13 13  
... ...
spec/lib/gitlab/ldap/ldap_user_auth_spec.rb
... ... @@ -6,7 +6,7 @@ describe Gitlab::LDAP do
6 6 before do
7 7 Gitlab.config.stub(omniauth: {})
8 8  
9   - @info = mock(
  9 + @info = double(
10 10 uid: '12djsak321',
11 11 name: 'John',
12 12 email: 'john@mail.com'
... ... @@ -15,7 +15,7 @@ describe Gitlab::LDAP do
15 15  
16 16 describe :find_for_ldap_auth do
17 17 before do
18   - @auth = mock(
  18 + @auth = double(
19 19 uid: '12djsak321',
20 20 info: @info,
21 21 provider: 'ldap'
... ...
spec/lib/oauth_spec.rb
... ... @@ -6,7 +6,7 @@ describe Gitlab::OAuth::User do
6 6 before do
7 7 Gitlab.config.stub(omniauth: {})
8 8  
9   - @info = mock(
  9 + @info = double(
10 10 uid: '12djsak321',
11 11 name: 'John',
12 12 email: 'john@mail.com'
... ... @@ -15,7 +15,7 @@ describe Gitlab::OAuth::User do
15 15  
16 16 describe :create do
17 17 it "should create user from LDAP" do
18   - @auth = mock(info: @info, provider: 'ldap')
  18 + @auth = double(info: @info, provider: 'ldap')
19 19 user = gl_auth.create(@auth)
20 20  
21 21 user.should be_valid
... ... @@ -24,7 +24,7 @@ describe Gitlab::OAuth::User do
24 24 end
25 25  
26 26 it "should create user from Omniauth" do
27   - @auth = mock(info: @info, provider: 'twitter')
  27 + @auth = double(info: @info, provider: 'twitter')
28 28 user = gl_auth.create(@auth)
29 29  
30 30 user.should be_valid
... ... @@ -33,7 +33,7 @@ describe Gitlab::OAuth::User do
33 33 end
34 34  
35 35 it "should apply defaults to user" do
36   - @auth = mock(info: @info, provider: 'ldap')
  36 + @auth = double(info: @info, provider: 'ldap')
37 37 user = gl_auth.create(@auth)
38 38  
39 39 user.should be_valid
... ...
spec/models/concerns/issuable_spec.rb
... ... @@ -34,7 +34,7 @@ describe Issue, "Issuable" do
34 34 let!(:searchable_issue) { create(:issue, title: "Searchable issue") }
35 35  
36 36 it "matches by title" do
37   - described_class.search('able').all.should == [searchable_issue]
  37 + described_class.search('able').should == [searchable_issue]
38 38 end
39 39 end
40 40  
... ...
spec/models/event_spec.rb
... ... @@ -67,12 +67,12 @@ describe Event do
67 67 end
68 68  
69 69 describe 'Team events' do
70   - let(:user_project) { stub.as_null_object }
  70 + let(:user_project) { double.as_null_object }
71 71 let(:observer) { UsersProjectObserver.instance }
72 72  
73 73 before {
74 74 Event.should_receive :create
75   - observer.stub(notification: stub.as_null_object)
  75 + observer.stub(notification: double.as_null_object)
76 76 }
77 77  
78 78 describe "Joined project team" do
... ...
spec/models/forked_project_link_spec.rb
... ... @@ -59,7 +59,7 @@ end
59 59  
60 60 def fork_project(from_project, user)
61 61 context = Projects::ForkContext.new(from_project, user)
62   - shell = mock("gitlab_shell")
  62 + shell = double("gitlab_shell")
63 63 shell.stub(fork_repository: true)
64 64 context.stub(gitlab_shell: shell)
65 65 context.execute
... ...
spec/models/merge_request_spec.rb
... ... @@ -107,9 +107,9 @@ describe MergeRequest do
107 107 describe 'detection of issues to be closed' do
108 108 let(:issue0) { create :issue, project: subject.project }
109 109 let(:issue1) { create :issue, project: subject.project }
110   - let(:commit0) { mock('commit0', closes_issues: [issue0]) }
111   - let(:commit1) { mock('commit1', closes_issues: [issue0]) }
112   - let(:commit2) { mock('commit2', closes_issues: [issue1]) }
  110 + let(:commit0) { double('commit0', closes_issues: [issue0]) }
  111 + let(:commit1) { double('commit1', closes_issues: [issue0]) }
  112 + let(:commit2) { double('commit2', closes_issues: [issue1]) }
113 113  
114 114 before do
115 115 subject.stub(commits: [commit0, commit1, commit2])
... ...
spec/observers/note_observer_spec.rb
... ... @@ -2,7 +2,7 @@ require 'spec_helper'
2 2  
3 3 describe NoteObserver do
4 4 subject { NoteObserver.instance }
5   - before { subject.stub(notification: mock('NotificationService').as_null_object) }
  5 + before { subject.stub(notification: double('NotificationService').as_null_object) }
6 6  
7 7 let(:team_without_author) { (1..2).map { |n| double :user, id: n } }
8 8 let(:note) { double(:note).as_null_object }
... ...
spec/requests/api/groups_spec.rb
... ... @@ -147,7 +147,7 @@ describe API::API do
147 147 describe "POST /groups/:id/projects/:project_id" do
148 148 let(:project) { create(:project) }
149 149 before(:each) do
150   - project.stub!(:transfer).and_return(true)
  150 + project.stub(:transfer).and_return(true)
151 151 Project.stub(:find).and_return(project)
152 152 end
153 153  
... ...