summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-04-17 18:27:42 +0300
committerValery Sizov <vsv2711@gmail.com>2015-04-17 18:27:42 +0300
commit2a65d368e3b0c2ed2a788b42bb3207b82eeb1afe (patch)
treea8f9e722b082be6ba98159023ec3b0687c4513fa
parentf73c162835c11a357baf59430fddceb02e22259b (diff)
downloadgitlab-ci-2a65d368e3b0c2ed2a788b42bb3207b82eeb1afe.tar.gz
Improved test coverageimprove_test_coverage
-rw-r--r--Gemfile2
-rw-r--r--Gemfile.lock2
-rw-r--r--app/controllers/projects_controller.rb2
-rw-r--r--app/views/jobs/_deploy_job_edit.html.haml8
-rw-r--r--app/views/jobs/_edit.html.haml12
-rw-r--r--spec/features/jobs_spec.rb39
-rw-r--r--spec/features/projects_spec.rb9
-rw-r--r--spec/spec_helper.rb2
-rw-r--r--spec/support/db_cleaner.rb39
9 files changed, 98 insertions, 17 deletions
diff --git a/Gemfile b/Gemfile
index 778b4eb..b0b803e 100644
--- a/Gemfile
+++ b/Gemfile
@@ -102,7 +102,7 @@ group :development, :test do
gem 'factory_girl_rails'
gem "ffaker"
gem "byebug"
-
+ gem "database_cleaner"
gem 'shoulda-matchers'
gem 'guard-rspec'
gem 'rb-fsevent', require: darwin_only('rb-fsevent')
diff --git a/Gemfile.lock b/Gemfile.lock
index 9160d12..41bc118 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -91,6 +91,7 @@ GEM
thor
crack (0.4.1)
safe_yaml (~> 0.9.0)
+ database_cleaner (1.3.0)
debugger-linecache (1.2.0)
default_value_for (3.0.0.1)
activerecord (>= 3.2.0, < 5.0)
@@ -376,6 +377,7 @@ DEPENDENCIES
capybara
coffee-rails (~> 4.0.0)
coveralls
+ database_cleaner
default_value_for (~> 3.0.0)
email_spec
factory_girl_rails
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 2fbf3f6..3287ba4 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -66,7 +66,7 @@ class ProjectsController < ApplicationController
EventService.new.change_project_settings(current_user, project)
- redirect_to project, notice: 'Project was successfully updated.'
+ redirect_to :back, notice: 'Project was successfully updated.'
else
render action: "edit"
end
diff --git a/app/views/jobs/_deploy_job_edit.html.haml b/app/views/jobs/_deploy_job_edit.html.haml
index 4a39c17..5765784 100644
--- a/app/views/jobs/_deploy_job_edit.html.haml
+++ b/app/views/jobs/_deploy_job_edit.html.haml
@@ -12,11 +12,11 @@
= job_form.hidden_field :job_type, value: "deploy"
.form-group
- = f.label :name, 'Name', class: 'control-label'
+ = job_form.label :name, 'Name', class: 'control-label'
.col-sm-10
= job_form.text_field :name, class: 'form-control', placeholder: "Staging"
.form-group
- = label_tag :tag_list, class: 'control-label' do
+ = job_form.label :tag_list, class: 'control-label' do
Tags
.col-sm-10
= job_form.text_field :tag_list, class: 'form-control'
@@ -25,7 +25,7 @@
Leave blank if you want this job to use any runner
.form-group
- = label_tag :refs, class: 'control-label' do
+ = job_form.label :refs, class: 'control-label' do
Refs
.col-sm-10
= job_form.text_field :refs, class: 'form-control', placeholder: "master, staging, feature/*, tags/testing*"
@@ -35,7 +35,7 @@
Accepts strings and glob pattern syntax
.form-group
- = f.label :commands, 'Script', class: 'control-label'
+ = job_form.label :commands, 'Script', class: 'control-label'
.col-sm-10
= job_form.text_area :commands, class: 'form-control', rows: 10, placeholder: "bundle exec rake spec"
%p.light
diff --git a/app/views/jobs/_edit.html.haml b/app/views/jobs/_edit.html.haml
index c3cb6aa..d748b22 100644
--- a/app/views/jobs/_edit.html.haml
+++ b/app/views/jobs/_edit.html.haml
@@ -10,20 +10,20 @@
= f.fields_for :jobs do |job_form|
- if job_form.object.job_type == "parallel" || job_form.object.new_record?
.form-group
- = f.label :name, 'Name', class: 'control-label'
+ = job_form.label :name, 'Name', class: 'control-label'
.col-sm-10
= job_form.text_field :name, class: 'form-control', placeholder: "Ex. cucumber"
.form-group
- = f.label :build_branches, 'Trigger', class: 'control-label'
+ = job_form.label :build_branches, 'Trigger', class: 'control-label'
.col-sm-10
.checkbox
- = f.label :build_branches, 'Builds commits', class: ''
+ = job_form.label :build_branches, 'Builds commits', class: ''
= job_form.check_box :build_branches
.checkbox
- = f.label :build_tags, 'Build tags', class: ''
+ = job_form.label :build_tags, 'Build tags', class: ''
= job_form.check_box :build_tags
.form-group
- = label_tag :tag_list, class: 'control-label' do
+ = job_form.label :tag_list, class: 'control-label' do
Tags
.col-sm-10
= job_form.text_field :tag_list, class: 'form-control'
@@ -32,7 +32,7 @@
Leave blank if you want this job to use any runner
.form-group
- = f.label :commands, 'Script', class: 'control-label'
+ = job_form.label :commands, 'Script', class: 'control-label'
.col-sm-10
= job_form.text_area :commands, class: 'form-control', rows: 10, placeholder: "bundle exec rake spec"
%p.light
diff --git a/spec/features/jobs_spec.rb b/spec/features/jobs_spec.rb
index 5091df8..6945a8f 100644
--- a/spec/features/jobs_spec.rb
+++ b/spec/features/jobs_spec.rb
@@ -15,12 +15,23 @@ describe "Jobs" do
it { page.should have_link 'Add a job' }
describe 'change job script' do
- before do
- fill_in 'project_jobs_attributes_0_commands', with: 'Wow'
+ it "updates job" do
+ fill_in 'Script', with: 'pwd'
+ fill_in 'Name', with: 'New Job'
+ fill_in 'Tags', with: 'Tags'
+ check "Builds commits"
+ check "Build tags"
+
click_button 'Save changes'
- end
- it { page.should have_content 'successfully updated'}
+ page.should have_content 'successfully updated'
+
+ find_field('Script').value.should eq 'pwd'
+ find_field('Name').value.should eq 'New Job'
+ find_field('Tags').value.should eq 'Tags'
+ find_field('Builds commits').should be_checked
+ find_field('Build tags').should be_checked
+ end
end
end
@@ -32,5 +43,25 @@ describe "Jobs" do
it { page.should have_content @project.name }
it { page.should have_link 'Add a job' }
it { page.should have_content 'Deploy jobs are scripts you want CI to run on succeeding all parallel builds' }
+
+ describe 'change job script', js: true do
+ it "updates deploy job" do
+ click_on "Add a job"
+
+ fill_in 'Script', with: 'pwd'
+ fill_in 'Name', with: 'New Job'
+ fill_in 'Tags', with: 'Tags'
+ fill_in 'Refs', with: 'master'
+
+ click_button 'Save changes'
+
+ page.should have_content 'successfully updated'
+
+ find_field('Script').value.should eq 'pwd'
+ find_field('Name').value.should eq 'New Job'
+ find_field('Tags').value.should eq 'Tags'
+ find_field('Refs').value.should eq 'master'
+ end
+ end
end
end
diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb
index 034dfc1..449b322 100644
--- a/spec/features/projects_spec.rb
+++ b/spec/features/projects_spec.rb
@@ -31,6 +31,15 @@ describe "Projects" do
it { page.should have_content @project.name }
it { page.should have_content 'Build Schedule' }
+
+ it "updates configuration" do
+ fill_in 'Name', with: 'Documentcloud / Underscore1'
+ click_button 'Save changes'
+
+ page.should have_content 'successfully updated'
+
+ find_field('Name').value.should eq 'Documentcloud / Underscore1'
+ end
end
describe "GET /projects/:id/charts" do
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 29329b7..4e8ef9a 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -44,7 +44,7 @@ RSpec.configure do |config|
# 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
# instead of true.
- config.use_transactional_fixtures = true
+ config.use_transactional_fixtures = false
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
diff --git a/spec/support/db_cleaner.rb b/spec/support/db_cleaner.rb
new file mode 100644
index 0000000..d2d532d
--- /dev/null
+++ b/spec/support/db_cleaner.rb
@@ -0,0 +1,39 @@
+# RSpec.configure do |config|
+
+# config.around(:each) do |example|
+# DatabaseCleaner.strategy = :transaction
+# DatabaseCleaner.clean_with(:truncation)
+# DatabaseCleaner.cleaning do
+# example.run
+# end
+# end
+
+# config.around(:each, js: true) do |example|
+# DatabaseCleaner.strategy = :truncation
+# DatabaseCleaner.clean_with(:truncation)
+# DatabaseCleaner.cleaning do
+# example.run
+# end
+# end
+# end
+RSpec.configure do |config|
+ config.before(:suite) do
+ DatabaseCleaner.clean_with(:truncation)
+ end
+
+ config.before(:each) do
+ DatabaseCleaner.strategy = :transaction
+ end
+
+ config.before(:each, :js => true) do
+ DatabaseCleaner.strategy = :truncation
+ end
+
+ config.before(:each) do
+ DatabaseCleaner.start
+ end
+
+ config.after(:each) do
+ DatabaseCleaner.clean
+ end
+end