diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-06-23 11:44:03 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-06-23 11:44:03 +0300 |
commit | f40b99d02ee9411e5a7f9a93e3e6cf33c1d7890e (patch) | |
tree | a55ff4f3ceaa24fcb008114f62b8ac377db6a129 /spec/helpers | |
parent | 9369adb93d119ca349add2b7f80d6a9b4bbd6703 (diff) | |
parent | 4aa1fdd347d1df4001d9e1298e6dc09c0c478c2e (diff) |
Merge branch 'master' into rubocop-for-tests
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Conflicts:
spec/features/issues_spec.rb
spec/models/forked_project_link_spec.rb
spec/models/hooks/service_hook_spec.rb
spec/models/hooks/web_hook_spec.rb
spec/models/project_services/hipchat_service_spec.rb
spec/requests/api/project_members_spec.rb
spec/requests/api/projects_spec.rb
spec/requests/api/system_hooks_spec.rb
spec/services/archive_repository_service_spec.rb
spec/support/matchers.rb
spec/tasks/gitlab/backup_rake_spec.rb
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/application_helper_spec.rb | 22 | ||||
-rw-r--r-- | spec/helpers/broadcast_messages_helper_spec.rb | 10 | ||||
-rw-r--r-- | spec/helpers/diff_helper_spec.rb | 6 | ||||
-rw-r--r-- | spec/helpers/groups_helper.rb | 4 | ||||
-rw-r--r-- | spec/helpers/notifications_helper_spec.rb | 9 | ||||
-rw-r--r-- | spec/helpers/submodule_helper_spec.rb | 26 |
6 files changed, 37 insertions, 40 deletions
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 1297e789793..8fd3d8f407b 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -40,15 +40,15 @@ describe ApplicationHelper do end describe 'project_icon' do - avatar_file_path = File.join(Rails.root, 'public', 'gitlab_logo.png') + avatar_file_path = File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif') it 'should return an url for the avatar' do project = create(:project) project.avatar = File.open(avatar_file_path) project.save! - avatar_url = "http://localhost/uploads/project/avatar/#{ project.id }/gitlab_logo.png" + avatar_url = "http://localhost/uploads/project/avatar/#{ project.id }/banana_sample.gif" expect(project_icon("#{project.namespace.to_param}/#{project.to_param}").to_s).to eq( - "<img alt=\"Gitlab logo\" src=\"#{avatar_url}\" />" + "<img alt=\"Banana sample\" src=\"#{avatar_url}\" />" ) end @@ -65,25 +65,25 @@ describe ApplicationHelper do end describe 'avatar_icon' do - avatar_file_path = File.join(Rails.root, 'public', 'gitlab_logo.png') + avatar_file_path = File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif') it 'should return an url for the avatar' do user = create(:user) user.avatar = File.open(avatar_file_path) user.save! expect(avatar_icon(user.email).to_s). - to match("/uploads/user/avatar/#{ user.id }/gitlab_logo.png") + to match("/uploads/user/avatar/#{ user.id }/banana_sample.gif") end it 'should return an url for the avatar with relative url' do - Gitlab.config.gitlab.stub(relative_url_root: '/gitlab') - Gitlab.config.gitlab.stub(url: Settings.send(:build_gitlab_url)) + allow(Gitlab.config.gitlab).to receive(:relative_url_root).and_return('/gitlab') + allow(Gitlab.config.gitlab).to receive(:url).and_return(Settings.send(:build_gitlab_url)) user = create(:user) user.avatar = File.open(avatar_file_path) user.save! expect(avatar_icon(user.email).to_s). - to match("/gitlab/uploads/user/avatar/#{ user.id }/gitlab_logo.png") + to match("/gitlab/uploads/user/avatar/#{ user.id }/banana_sample.gif") end it 'should call gravatar_icon when no avatar is present' do @@ -97,7 +97,7 @@ describe ApplicationHelper do let(:user_email) { 'user@email.com' } it 'should return a generic avatar path when Gravatar is disabled' do - ApplicationSetting.any_instance.stub(gravatar_enabled?: false) + allow_any_instance_of(ApplicationSetting).to receive(:gravatar_enabled?).and_return(false) expect(gravatar_icon(user_email)).to match('no_avatar.png') end @@ -106,13 +106,13 @@ describe ApplicationHelper do end it 'should return default gravatar url' do - Gitlab.config.gitlab.stub(https: false) + allow(Gitlab.config.gitlab).to receive(:https).and_return(false) url = 'http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118' expect(gravatar_icon(user_email)).to match(url) end it 'should use SSL when appropriate' do - Gitlab.config.gitlab.stub(https: true) + allow(Gitlab.config.gitlab).to receive(:https).and_return(true) expect(gravatar_icon(user_email)).to match('https://secure.gravatar.com') end diff --git a/spec/helpers/broadcast_messages_helper_spec.rb b/spec/helpers/broadcast_messages_helper_spec.rb index f6df12662bb..c7c6f45d144 100644 --- a/spec/helpers/broadcast_messages_helper_spec.rb +++ b/spec/helpers/broadcast_messages_helper_spec.rb @@ -2,20 +2,20 @@ require 'spec_helper' describe BroadcastMessagesHelper do describe 'broadcast_styling' do - let(:broadcast_message) { double(color: "", font: "") } + let(:broadcast_message) { double(color: '', font: '') } context "default style" do it "should have no style" do - expect(broadcast_styling(broadcast_message)).to match('') + expect(broadcast_styling(broadcast_message)).to eq '' end end - context "customiezd style" do - before { broadcast_message.stub(color: "#f2dede", font: "#b94a48") } + context "customized style" do + let(:broadcast_message) { double(color: "#f2dede", font: '#b94a48') } it "should have a customized style" do expect(broadcast_styling(broadcast_message)). - to match('background-color:#f2dede;color:#b94a48') + to match('background-color: #f2dede; color: #b94a48') end end end diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb index e0be2df0e5e..7c96a74e581 100644 --- a/spec/helpers/diff_helper_spec.rb +++ b/spec/helpers/diff_helper_spec.rb @@ -48,19 +48,19 @@ describe DiffHelper do end it 'should return only the first file if the diff line count in the 2nd file takes the total beyond safe limits' do - diffs[1].diff.stub(lines: [""] * 4999) #simulate 4999 lines + allow(diffs[1].diff).to receive(:lines).and_return([""] * 4999) #simulate 4999 lines expect(safe_diff_files(diffs).length).to eq(1) end it 'should return all files from a commit that is beyond safe limit for numbers of lines if force diff is true' do allow(controller).to receive(:params) { { force_show_diff: true } } - diffs[1].diff.stub(lines: [""] * 4999) #simulate 4999 lines + allow(diffs[1].diff).to receive(:lines).and_return([""] * 4999) #simulate 4999 lines expect(safe_diff_files(diffs).length).to eq(2) end it 'should return only the first file if the diff line count in the 2nd file takes the total beyond hard limits' do allow(controller).to receive(:params) { { force_show_diff: true } } - diffs[1].diff.stub(lines: [""] * 49999) #simulate 49999 lines + allow(diffs[1].diff).to receive(:lines).and_return([""] * 49999) #simulate 49999 lines expect(safe_diff_files(diffs).length).to eq(1) end diff --git a/spec/helpers/groups_helper.rb b/spec/helpers/groups_helper.rb index 3e99ab84ec9..5d174460681 100644 --- a/spec/helpers/groups_helper.rb +++ b/spec/helpers/groups_helper.rb @@ -2,14 +2,14 @@ require 'spec_helper' describe GroupsHelper do describe 'group_icon' do - avatar_file_path = File.join(Rails.root, 'public', 'gitlab_logo.png') + avatar_file_path = File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif') it 'should return an url for the avatar' do group = create(:group) group.avatar = File.open(avatar_file_path) group.save! expect(group_icon(group.path).to_s). - to match("/uploads/group/avatar/#{ group.id }/gitlab_logo.png") + to match("/uploads/group/avatar/#{ group.id }/banana_sample.gif") end it 'should give default avatar_icon when no avatar is present' do diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index 482cb33e94f..f1aba4cfdf3 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -1,14 +1,11 @@ require 'spec_helper' describe NotificationsHelper do - include FontAwesome::Rails::IconHelper - include IconsHelper - describe 'notification_icon' do let(:notification) { double(disabled?: false, participating?: false, watch?: false) } context "disabled notification" do - before { notification.stub(disabled?: true) } + before { allow(notification).to receive(:disabled?).and_return(true) } it "has a red icon" do expect(notification_icon(notification)).to match('class="fa fa-volume-off ns-mute"') @@ -16,7 +13,7 @@ describe NotificationsHelper do end context "participating notification" do - before { notification.stub(participating?: true) } + before { allow(notification).to receive(:participating?).and_return(true) } it "has a blue icon" do expect(notification_icon(notification)).to match('class="fa fa-volume-down ns-part"') @@ -24,7 +21,7 @@ describe NotificationsHelper do end context "watched notification" do - before { notification.stub(watch?: true) } + before { allow(notification).to receive(:watch?).and_return(true) } it "has a green icon" do expect(notification_icon(notification)).to match('class="fa fa-volume-up ns-watch"') diff --git a/spec/helpers/submodule_helper_spec.rb b/spec/helpers/submodule_helper_spec.rb index e98b75afabc..a7abf9d3839 100644 --- a/spec/helpers/submodule_helper_spec.rb +++ b/spec/helpers/submodule_helper_spec.rb @@ -14,41 +14,41 @@ describe SubmoduleHelper do context 'submodule on self' do before do - Gitlab.config.gitlab.stub(protocol: 'http') # set this just to be sure + allow(Gitlab.config.gitlab).to receive(:protocol).and_return('http') # set this just to be sure end it 'should detect ssh on standard port' do - Gitlab.config.gitlab_shell.stub(ssh_port: 22) # set this just to be sure - Gitlab.config.gitlab_shell.stub(ssh_path_prefix: Settings.send(:build_gitlab_shell_ssh_path_prefix)) + allow(Gitlab.config.gitlab_shell).to receive(:ssh_port).and_return(22) # set this just to be sure + allow(Gitlab.config.gitlab_shell).to receive(:ssh_path_prefix).and_return(Settings.send(:build_gitlab_shell_ssh_path_prefix)) stub_url([ config.user, '@', config.host, ':gitlab-org/gitlab-ce.git' ].join('')) expect(submodule_links(submodule_item)).to eq([ namespace_project_path('gitlab-org', 'gitlab-ce'), namespace_project_tree_path('gitlab-org', 'gitlab-ce', 'hash') ]) end it 'should detect ssh on non-standard port' do - Gitlab.config.gitlab_shell.stub(ssh_port: 2222) - Gitlab.config.gitlab_shell.stub(ssh_path_prefix: Settings.send(:build_gitlab_shell_ssh_path_prefix)) + allow(Gitlab.config.gitlab_shell).to receive(:ssh_port).and_return(2222) + allow(Gitlab.config.gitlab_shell).to receive(:ssh_path_prefix).and_return(Settings.send(:build_gitlab_shell_ssh_path_prefix)) stub_url([ 'ssh://', config.user, '@', config.host, ':2222/gitlab-org/gitlab-ce.git' ].join('')) expect(submodule_links(submodule_item)).to eq([ namespace_project_path('gitlab-org', 'gitlab-ce'), namespace_project_tree_path('gitlab-org', 'gitlab-ce', 'hash') ]) end it 'should detect http on standard port' do - Gitlab.config.gitlab.stub(port: 80) - Gitlab.config.gitlab.stub(url: Settings.send(:build_gitlab_url)) + allow(Gitlab.config.gitlab).to receive(:port).and_return(80) + allow(Gitlab.config.gitlab).to receive(:url).and_return(Settings.send(:build_gitlab_url)) stub_url([ 'http://', config.host, '/gitlab-org/gitlab-ce.git' ].join('')) expect(submodule_links(submodule_item)).to eq([ namespace_project_path('gitlab-org', 'gitlab-ce'), namespace_project_tree_path('gitlab-org', 'gitlab-ce', 'hash') ]) end it 'should detect http on non-standard port' do - Gitlab.config.gitlab.stub(port: 3000) - Gitlab.config.gitlab.stub(url: Settings.send(:build_gitlab_url)) + allow(Gitlab.config.gitlab).to receive(:port).and_return(3000) + allow(Gitlab.config.gitlab).to receive(:url).and_return(Settings.send(:build_gitlab_url)) stub_url([ 'http://', config.host, ':3000/gitlab-org/gitlab-ce.git' ].join('')) expect(submodule_links(submodule_item)).to eq([ namespace_project_path('gitlab-org', 'gitlab-ce'), namespace_project_tree_path('gitlab-org', 'gitlab-ce', 'hash') ]) end it 'should work with relative_url_root' do - Gitlab.config.gitlab.stub(port: 80) # set this just to be sure - Gitlab.config.gitlab.stub(relative_url_root: '/gitlab/root') - Gitlab.config.gitlab.stub(url: Settings.send(:build_gitlab_url)) + allow(Gitlab.config.gitlab).to receive(:port).and_return(80) # set this just to be sure + allow(Gitlab.config.gitlab).to receive(:relative_url_root).and_return('/gitlab/root') + allow(Gitlab.config.gitlab).to receive(:url).and_return(Settings.send(:build_gitlab_url)) stub_url([ 'http://', config.host, '/gitlab/root/gitlab-org/gitlab-ce.git' ].join('')) expect(submodule_links(submodule_item)).to eq([ namespace_project_path('gitlab-org', 'gitlab-ce'), namespace_project_tree_path('gitlab-org', 'gitlab-ce', 'hash') ]) end @@ -156,6 +156,6 @@ describe SubmoduleHelper do end def stub_url(url) - repo.stub(submodule_url_for: url) + allow(repo).to receive(:submodule_url_for).and_return(url) end end |