summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-07-08 21:42:29 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-07-08 21:42:29 +0000
commit27a9ff8264ff45a3753dd64ff4af62c121ff7f0b (patch)
tree6b8b06f7fdec0610807c9beab80fbda24be6fddf /spec
parent512bb5ba285ed02db97d51d439cc81d9bd08a03d (diff)
parent098ced4faad8d1048d6735f5b3ad6da6aa49fcfe (diff)
downloadgitlab-ce-27a9ff8264ff45a3753dd64ff4af62c121ff7f0b.tar.gz
Merge branch 'rs-dev-issue-2372' into 'master'
Filter by issues/merge requests without a milestone Closes internal https://dev.gitlab.org/gitlab/gitlabhq/issues/2372 See merge request !886
Diffstat (limited to 'spec')
-rw-r--r--spec/features/groups_spec.rb2
-rw-r--r--spec/features/issues/filter_by_milestone_spec.rb36
-rw-r--r--spec/features/issues_spec.rb16
-rw-r--r--spec/features/login_spec.rb2
-rw-r--r--spec/features/markdown_spec.rb2
-rw-r--r--spec/features/merge_requests/filter_by_milestone_spec.rb36
-rw-r--r--spec/features/notes_on_merge_requests_spec.rb2
-rw-r--r--spec/features/password_reset_spec.rb2
-rw-r--r--spec/features/profile_spec.rb6
-rw-r--r--spec/features/profiles/preferences_spec.rb2
-rw-r--r--spec/features/projects_spec.rb2
-rw-r--r--spec/features/users_spec.rb2
-rw-r--r--spec/requests/api/projects_spec.rb4
-rw-r--r--spec/services/create_snippet_service_spec.rb6
-rw-r--r--spec/services/git_push_service_spec.rb8
-rw-r--r--spec/services/projects/create_service_spec.rb4
-rw-r--r--spec/services/projects/update_service_spec.rb4
-rw-r--r--spec/services/update_snippet_service_spec.rb6
-rw-r--r--spec/support/stub_configuration.rb26
19 files changed, 115 insertions, 53 deletions
diff --git a/spec/features/groups_spec.rb b/spec/features/groups_spec.rb
index edc1c63a0aa..891df65216d 100644
--- a/spec/features/groups_spec.rb
+++ b/spec/features/groups_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-feature 'Group' do
+feature 'Group', feature: true do
describe 'description' do
let(:group) { create(:group) }
let(:path) { group_path(group) }
diff --git a/spec/features/issues/filter_by_milestone_spec.rb b/spec/features/issues/filter_by_milestone_spec.rb
new file mode 100644
index 00000000000..f600f8684ac
--- /dev/null
+++ b/spec/features/issues/filter_by_milestone_spec.rb
@@ -0,0 +1,36 @@
+require 'rails_helper'
+
+feature 'Issue filtering by Milestone', feature: true do
+ include Select2Helper
+
+ let(:project) { create(:project, :public) }
+ let(:milestone) { create(:milestone, project: project) }
+
+ scenario 'filters by no Milestone', js: true do
+ create(:issue, project: project)
+ create(:issue, project: project, milestone: milestone)
+
+ visit_issues(project)
+ filter_by_milestone(Milestone::None.title)
+
+ expect(page).to have_css('.issue-title', count: 1)
+ end
+
+ scenario 'filters by a specific Milestone', js: true do
+ create(:issue, project: project, milestone: milestone)
+ create(:issue, project: project)
+
+ visit_issues(project)
+ filter_by_milestone(milestone.title)
+
+ expect(page).to have_css('.issue-title', count: 1)
+ end
+
+ def visit_issues(project)
+ visit namespace_project_issues_path(project.namespace, project)
+ end
+
+ def filter_by_milestone(title)
+ select2(title, from: '#milestone_title')
+ end
+end
diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb
index 808a6eeb958..32fd4065bb4 100644
--- a/spec/features/issues_spec.rb
+++ b/spec/features/issues_spec.rb
@@ -92,22 +92,6 @@ describe 'Issues', feature: true do
let(:issue) { @issue }
- it 'should allow filtering by issues with no specified milestone' do
- visit namespace_project_issues_path(project.namespace, project, milestone_title: IssuableFinder::NONE)
-
- expect(page).not_to have_content 'foobar'
- expect(page).to have_content 'barbaz'
- expect(page).to have_content 'gitlab'
- end
-
- it 'should allow filtering by a specified milestone' do
- visit namespace_project_issues_path(project.namespace, project, milestone_title: issue.milestone.title)
-
- expect(page).to have_content 'foobar'
- expect(page).not_to have_content 'barbaz'
- expect(page).not_to have_content 'gitlab'
- end
-
it 'should allow filtering by issues with no specified assignee' do
visit namespace_project_issues_path(project.namespace, project, assignee_id: IssuableFinder::NONE)
diff --git a/spec/features/login_spec.rb b/spec/features/login_spec.rb
index 046a9f6191d..cef432e512b 100644
--- a/spec/features/login_spec.rb
+++ b/spec/features/login_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-feature 'Login' do
+feature 'Login', feature: true do
describe 'with two-factor authentication' do
context 'with valid username/password' do
let(:user) { create(:user, :two_factor) }
diff --git a/spec/features/markdown_spec.rb b/spec/features/markdown_spec.rb
index 902968cebcb..b8199aa5e61 100644
--- a/spec/features/markdown_spec.rb
+++ b/spec/features/markdown_spec.rb
@@ -32,7 +32,7 @@ require 'erb'
#
# See the MarkdownFeature class for setup details.
-describe 'GitLab Markdown' do
+describe 'GitLab Markdown', feature: true do
include ActionView::Helpers::TagHelper
include ActionView::Helpers::UrlHelper
include Capybara::Node::Matchers
diff --git a/spec/features/merge_requests/filter_by_milestone_spec.rb b/spec/features/merge_requests/filter_by_milestone_spec.rb
new file mode 100644
index 00000000000..f70214e1122
--- /dev/null
+++ b/spec/features/merge_requests/filter_by_milestone_spec.rb
@@ -0,0 +1,36 @@
+require 'rails_helper'
+
+feature 'Merge Request filtering by Milestone', feature: true do
+ include Select2Helper
+
+ let(:project) { create(:project, :public) }
+ let(:milestone) { create(:milestone, project: project) }
+
+ scenario 'filters by no Milestone', js: true do
+ create(:merge_request, :with_diffs, source_project: project)
+ create(:merge_request, :simple, source_project: project, milestone: milestone)
+
+ visit_merge_requests(project)
+ filter_by_milestone(Milestone::None.title)
+
+ expect(page).to have_css('.merge-request-title', count: 1)
+ end
+
+ scenario 'filters by a specific Milestone', js: true do
+ create(:merge_request, :with_diffs, source_project: project, milestone: milestone)
+ create(:merge_request, :simple, source_project: project)
+
+ visit_merge_requests(project)
+ filter_by_milestone(milestone.title)
+
+ expect(page).to have_css('.merge-request-title', count: 1)
+ end
+
+ def visit_merge_requests(project)
+ visit namespace_project_merge_requests_path(project.namespace, project)
+ end
+
+ def filter_by_milestone(title)
+ select2(title, from: '#milestone_title')
+ end
+end
diff --git a/spec/features/notes_on_merge_requests_spec.rb b/spec/features/notes_on_merge_requests_spec.rb
index ad37b589b84..d7cb3b2e86e 100644
--- a/spec/features/notes_on_merge_requests_spec.rb
+++ b/spec/features/notes_on_merge_requests_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'Comments' do
+describe 'Comments', feature: true do
include RepoHelpers
describe 'On a merge request', js: true, feature: true do
diff --git a/spec/features/password_reset_spec.rb b/spec/features/password_reset_spec.rb
index a34efce09ef..2b6311e4fd7 100644
--- a/spec/features/password_reset_spec.rb
+++ b/spec/features/password_reset_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-feature 'Password reset' do
+feature 'Password reset', feature: true do
def forgot_password
click_on 'Forgot your password?'
fill_in 'Email', with: user.email
diff --git a/spec/features/profile_spec.rb b/spec/features/profile_spec.rb
index 9fe2e610555..c80253fead8 100644
--- a/spec/features/profile_spec.rb
+++ b/spec/features/profile_spec.rb
@@ -9,8 +9,7 @@ describe 'Profile account page', feature: true do
describe 'when signup is enabled' do
before do
- allow_any_instance_of(ApplicationSetting).
- to receive(:signup_enabled?).and_return(true)
+ stub_application_setting(signup_enabled: true)
visit profile_account_path
end
@@ -24,8 +23,7 @@ describe 'Profile account page', feature: true do
describe 'when signup is disabled' do
before do
- allow_any_instance_of(ApplicationSetting).
- to receive(:signup_enabled?).and_return(false)
+ stub_application_setting(signup_enabled: false)
visit profile_account_path
end
diff --git a/spec/features/profiles/preferences_spec.rb b/spec/features/profiles/preferences_spec.rb
index 03e78c533db..9bc6145dda4 100644
--- a/spec/features/profiles/preferences_spec.rb
+++ b/spec/features/profiles/preferences_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'Profile > Preferences' do
+describe 'Profile > Preferences', feature: true do
let(:user) { create(:user) }
before do
diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb
index f8eea70ec4a..c8d44efdc8b 100644
--- a/spec/features/projects_spec.rb
+++ b/spec/features/projects_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-feature 'Project' do
+feature 'Project', feature: true do
describe 'description' do
let(:project) { create(:project) }
let(:path) { namespace_project_path(project.namespace, project) }
diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb
index a4c3dfe9205..efcb8a31abe 100644
--- a/spec/features/users_spec.rb
+++ b/spec/features/users_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-feature 'Users' do
+feature 'Users', feature: true do
scenario 'GET /users/sign_in creates a new user account' do
visit new_user_session_path
fill_in 'user_name', with: 'Name Surname'
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index e9ff832603f..4178bb2e836 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -220,9 +220,7 @@ describe API::API, api: true do
context 'when a visibility level is restricted' do
before do
@project = attributes_for(:project, { public: true })
- allow_any_instance_of(ApplicationSetting).to(
- receive(:restricted_visibility_levels).and_return([20])
- )
+ stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
end
it 'should not allow a non-admin to use a restricted visibility level' do
diff --git a/spec/services/create_snippet_service_spec.rb b/spec/services/create_snippet_service_spec.rb
index 08689c15ca8..8edabe9450b 100644
--- a/spec/services/create_snippet_service_spec.rb
+++ b/spec/services/create_snippet_service_spec.rb
@@ -14,11 +14,7 @@ describe CreateSnippetService do
context 'When public visibility is restricted' do
before do
- allow_any_instance_of(ApplicationSetting).to(
- receive(:restricted_visibility_levels).and_return(
- [Gitlab::VisibilityLevel::PUBLIC]
- )
- )
+ stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
@opts.merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
end
diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb
index 3373b97bfd4..62cef9db534 100644
--- a/spec/services/git_push_service_spec.rb
+++ b/spec/services/git_push_service_spec.rb
@@ -124,9 +124,7 @@ describe GitPushService do
end
it "when pushing a branch for the first time with default branch protection disabled" do
- allow(ApplicationSetting.current_application_settings).
- to receive(:default_branch_protection).
- and_return(Gitlab::Access::PROTECTION_NONE)
+ stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_NONE)
expect(project).to receive(:execute_hooks)
expect(project.default_branch).to eq("master")
@@ -135,9 +133,7 @@ describe GitPushService do
end
it "when pushing a branch for the first time with default branch protection set to 'developers can push'" do
- allow(ApplicationSetting.current_application_settings).
- to receive(:default_branch_protection).
- and_return(Gitlab::Access::PROTECTION_DEV_CAN_PUSH)
+ stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_DEV_CAN_PUSH)
expect(project).to receive(:execute_hooks)
expect(project.default_branch).to eq("master")
diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb
index 337dae592dd..97b206c9854 100644
--- a/spec/services/projects/create_service_spec.rb
+++ b/spec/services/projects/create_service_spec.rb
@@ -58,9 +58,7 @@ describe Projects::CreateService do
context 'restricted visibility level' do
before do
- allow_any_instance_of(ApplicationSetting).to(
- receive(:restricted_visibility_levels).and_return([20])
- )
+ stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
@opts.merge!(
visibility_level: Gitlab::VisibilityLevel.options['Public']
diff --git a/spec/services/projects/update_service_spec.rb b/spec/services/projects/update_service_spec.rb
index 0dd6980a44f..b347fa15f87 100644
--- a/spec/services/projects/update_service_spec.rb
+++ b/spec/services/projects/update_service_spec.rb
@@ -47,9 +47,7 @@ describe Projects::UpdateService do
context 'respect configured visibility restrictions setting' do
before(:each) do
- allow_any_instance_of(ApplicationSetting).to(
- receive(:restricted_visibility_levels).and_return([20])
- )
+ stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
end
context 'should be private when updated to private' do
diff --git a/spec/services/update_snippet_service_spec.rb b/spec/services/update_snippet_service_spec.rb
index 841ef9bfed1..d7c516e3934 100644
--- a/spec/services/update_snippet_service_spec.rb
+++ b/spec/services/update_snippet_service_spec.rb
@@ -14,11 +14,7 @@ describe UpdateSnippetService do
context 'When public visibility is restricted' do
before do
- allow_any_instance_of(ApplicationSetting).to(
- receive(:restricted_visibility_levels).and_return(
- [Gitlab::VisibilityLevel::PUBLIC]
- )
- )
+ stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
@snippet = create_snippet(@project, @user, @opts)
@opts.merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
diff --git a/spec/support/stub_configuration.rb b/spec/support/stub_configuration.rb
index ad86abdbb41..e4004ec8f79 100644
--- a/spec/support/stub_configuration.rb
+++ b/spec/support/stub_configuration.rb
@@ -1,5 +1,10 @@
module StubConfiguration
def stub_application_setting(messages)
+ add_predicates(messages)
+
+ # Stubbing both of these because we're not yet consistent with how we access
+ # current application settings
+ allow_any_instance_of(ApplicationSetting).to receive_messages(messages)
allow(Gitlab::CurrentSettings.current_application_settings).
to receive_messages(messages)
end
@@ -11,4 +16,25 @@ module StubConfiguration
def stub_gravatar_setting(messages)
allow(Gitlab.config.gravatar).to receive_messages(messages)
end
+
+ private
+
+ # Modifies stubbed messages to also stub possible predicate versions
+ #
+ # Examples:
+ #
+ # add_predicates(foo: true)
+ # # => {foo: true, foo?: true}
+ #
+ # add_predicates(signup_enabled?: false)
+ # # => {signup_enabled? false}
+ def add_predicates(messages)
+ # Only modify keys that aren't already predicates
+ keys = messages.keys.map(&:to_s).reject { |k| k.end_with?('?') }
+
+ keys.each do |key|
+ predicate = key + '?'
+ messages[predicate.to_sym] = messages[key.to_sym]
+ end
+ end
end