summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--features/step_definitions/project/projects_steps.rb2
-rw-r--r--features/support/env.rb4
-rw-r--r--spec/requests/api/issues_spec.rb (renamed from spec/api/issues_spec.rb)0
-rw-r--r--spec/requests/api/projects_spec.rb (renamed from spec/api/projects_spec.rb)0
-rw-r--r--spec/requests/api/users_spec.rb (renamed from spec/api/users_spec.rb)0
-rw-r--r--spec/spec_helper.rb37
-rw-r--r--spec/support/api.rb7
-rw-r--r--spec/support/api_helpers.rb9
-rw-r--r--spec/support/db_cleaner.rb18
-rw-r--r--spec/support/js_patch.rb6
-rw-r--r--spec/support/login.rb30
-rw-r--r--spec/support/login_helpers.rb23
-rw-r--r--spec/support/monkeypatch.rb (renamed from spec/monkeypatch.rb)0
-rw-r--r--spec/support/shared_examples.rb16
14 files changed, 59 insertions, 93 deletions
diff --git a/features/step_definitions/project/projects_steps.rb b/features/step_definitions/project/projects_steps.rb
index 3ff08d58448..d981e1f3802 100644
--- a/features/step_definitions/project/projects_steps.rb
+++ b/features/step_definitions/project/projects_steps.rb
@@ -1,4 +1,4 @@
-include LoginMacros
+include LoginHelpers
Given /^I signin as a user$/ do
login_as :user
diff --git a/features/support/env.rb b/features/support/env.rb
index b69a5fe7f07..80a465b472c 100644
--- a/features/support/env.rb
+++ b/features/support/env.rb
@@ -7,9 +7,9 @@ require 'cucumber/rails'
require 'webmock/cucumber'
WebMock.allow_net_connect!
-require Rails.root.join 'spec/monkeypatch'
require Rails.root.join 'spec/factories'
-require Rails.root.join 'spec/support/login'
+require Rails.root.join 'spec/support/monkeypatch'
+require Rails.root.join 'spec/support/login_helpers'
require Rails.root.join 'spec/support/valid_commit'
Capybara.default_selector = :css
diff --git a/spec/api/issues_spec.rb b/spec/requests/api/issues_spec.rb
index f6d8e3792c2..f6d8e3792c2 100644
--- a/spec/api/issues_spec.rb
+++ b/spec/requests/api/issues_spec.rb
diff --git a/spec/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index ff45619e58a..ff45619e58a 100644
--- a/spec/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
diff --git a/spec/api/users_spec.rb b/spec/requests/api/users_spec.rb
index 32b9379d212..32b9379d212 100644
--- a/spec/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index cd931475486..d3635ed1979 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -9,10 +9,8 @@ require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rails'
require 'capybara/rspec'
-require 'capybara/dsl'
require 'webmock/rspec'
require 'factories'
-require 'monkeypatch'
require 'email_spec'
require 'headless'
@@ -23,10 +21,13 @@ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
# Use capybara-webkit
Capybara.javascript_driver = :webkit
+WebMock.disable_net_connect!(allow_localhost: true)
+
RSpec.configure do |config|
config.mock_with :rspec
- config.include LoginMacros
+ config.include LoginHelpers, type: :request
+ config.include ApiHelpers, type: :request
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
@@ -38,35 +39,9 @@ RSpec.configure do |config|
headless.start
end
- config.before :each, type: :integration do
- DeviseSessionMock.disable
- end
-
config.before do
- if example.metadata[:js]
- DatabaseCleaner.strategy = :truncation
- Capybara::Selenium::Driver::DEFAULT_OPTIONS[:resynchronize] = true
- else
- DatabaseCleaner.strategy = :transaction
- end
-
- DatabaseCleaner.start
-
- WebMock.disable_net_connect!(allow_localhost: true)
-
# !!! Observers disabled by default in tests
- #
- # Use next code to enable observers
- # before(:each) { ActiveRecord::Base.observers.enable(:all) }
- #
- ActiveRecord::Base.observers.disable :all
- end
-
- config.after do
- DatabaseCleaner.clean
+ ActiveRecord::Base.observers.disable(:all)
+ # ActiveRecord::Base.observers.enable(:all)
end
-
- config.include RSpec::Rails::RequestExampleGroup, type: :request, example_group: {
- file_path: /spec\/api/
- }
end
diff --git a/spec/support/api.rb b/spec/support/api.rb
deleted file mode 100644
index d363d8b9a57..00000000000
--- a/spec/support/api.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-def api_prefix
- "/api/#{Gitlab::API::VERSION}"
-end
-
-def json_response
- JSON.parse(response.body)
-end
diff --git a/spec/support/api_helpers.rb b/spec/support/api_helpers.rb
new file mode 100644
index 00000000000..e35d5735ec3
--- /dev/null
+++ b/spec/support/api_helpers.rb
@@ -0,0 +1,9 @@
+module ApiHelpers
+ def api_prefix
+ "/api/#{Gitlab::API::VERSION}"
+ end
+
+ def json_response
+ JSON.parse(response.body)
+ end
+end
diff --git a/spec/support/db_cleaner.rb b/spec/support/db_cleaner.rb
new file mode 100644
index 00000000000..f1e072aa15f
--- /dev/null
+++ b/spec/support/db_cleaner.rb
@@ -0,0 +1,18 @@
+require 'database_cleaner'
+
+RSpec.configure do |config|
+ config.before do
+ if example.metadata[:js]
+ DatabaseCleaner.strategy = :truncation
+ Capybara::Selenium::Driver::DEFAULT_OPTIONS[:resynchronize] = true
+ else
+ DatabaseCleaner.strategy = :transaction
+ end
+
+ DatabaseCleaner.start
+ end
+
+ config.after do
+ DatabaseCleaner.clean
+ end
+end
diff --git a/spec/support/js_patch.rb b/spec/support/js_patch.rb
deleted file mode 100644
index 0d4ab264e85..00000000000
--- a/spec/support/js_patch.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-module JsPatch
- def confirm_js_popup
- page.evaluate_script("window.alert = function(msg) { return true; }")
- page.evaluate_script("window.confirm = function(msg) { return true; }")
- end
-end
diff --git a/spec/support/login.rb b/spec/support/login.rb
deleted file mode 100644
index 78a907bad0b..00000000000
--- a/spec/support/login.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-module LoginMacros
- def login_as role
- @user = User.create(email: "user#{User.count}@mail.com",
- name: "John Smith",
- password: "123456",
- password_confirmation: "123456",
- skype: 'user_skype')
-
- if role == :admin
- @user.admin = true
- @user.save!
- end
-
- visit new_user_session_path
- fill_in "user_email", with: @user.email
- fill_in "user_password", with: "123456"
- click_button "Sign in"
- end
-
- def login_with(user)
- visit new_user_session_path
- fill_in "user_email", with: user.email
- fill_in "user_password", with: "123456"
- click_button "Sign in"
- end
-
- def logout
- click_link "Logout" rescue nil
- end
-end
diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb
new file mode 100644
index 00000000000..769034e2286
--- /dev/null
+++ b/spec/support/login_helpers.rb
@@ -0,0 +1,23 @@
+module LoginHelpers
+ # Internal: Create and log in as a user of the specified role
+ #
+ # role - User role (e.g., :admin, :user)
+ def login_as(role)
+ @user = Factory(role)
+ login_with(@user)
+ end
+
+ # Internal: Login as the specified user
+ #
+ # user - User instance to login with
+ def login_with(user)
+ visit new_user_session_path
+ fill_in "user_email", with: user.email
+ fill_in "user_password", with: "123456"
+ click_button "Sign in"
+ end
+
+ def logout
+ click_link "Logout" rescue nil
+ end
+end
diff --git a/spec/monkeypatch.rb b/spec/support/monkeypatch.rb
index 855a31f06de..855a31f06de 100644
--- a/spec/monkeypatch.rb
+++ b/spec/support/monkeypatch.rb
diff --git a/spec/support/shared_examples.rb b/spec/support/shared_examples.rb
deleted file mode 100644
index 9fd207d0db2..00000000000
--- a/spec/support/shared_examples.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-shared_examples_for :project_side_pane do
- subject { page }
- it { should have_content((@project || project).name) }
- it { should have_content("Commits") }
- it { should have_content("Files") }
-end
-
-shared_examples_for :tree_view do
- subject { page }
-
- it "should have Tree View of project" do
- should have_content("app")
- should have_content("History")
- should have_content("Gemfile")
- end
-end