From aff713988bb9fe5b1d35f1986f44b5c1af5a5979 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 22 Dec 2015 08:47:23 +0100 Subject: Improve CI Lint specs (refactoring) --- spec/features/lint_spec.rb | 47 ++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/spec/features/lint_spec.rb b/spec/features/lint_spec.rb index 5d8f56e2cfb..441a3c702c7 100644 --- a/spec/features/lint_spec.rb +++ b/spec/features/lint_spec.rb @@ -1,28 +1,39 @@ require 'spec_helper' -describe "Lint" do +describe 'CI Lint' do before do login_as :user end - it "Yaml parsing", js: true do - content = File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) - visit ci_lint_path - fill_in "content", with: content - click_on "Validate" - within "table" do - expect(page).to have_content("Job - rspec") - expect(page).to have_content("Job - spinach") - expect(page).to have_content("Deploy Job - staging") - expect(page).to have_content("Deploy Job - production") + describe 'YAML parsing', js: true do + before do + visit ci_lint_path + fill_in 'content', with: yaml_content + click_on 'Validate' end - end - it "Yaml parsing with error", js: true do - visit ci_lint_path - fill_in "content", with: "" - click_on "Validate" - expect(page).to have_content("Status: syntax is incorrect") - expect(page).to have_content("Error: Please provide content of .gitlab-ci.yml") + context 'YAML is correct' do + let(:yaml_content) do + File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) + end + + it 'Yaml parsing' do + within "table" do + expect(page).to have_content('Job - rspec') + expect(page).to have_content('Job - spinach') + expect(page).to have_content('Deploy Job - staging') + expect(page).to have_content('Deploy Job - production') + end + end + end + + context 'YAML is incorrect' do + let(:yaml_content) { '' } + + it 'displays information about an error' do + expect(page).to have_content('Status: syntax is incorrect') + expect(page).to have_content('Error: Please provide content of .gitlab-ci.yml') + end + end end end -- cgit v1.2.1 From 2ed7b964fa56c14e4344530a1e6896c69dded58e Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 22 Dec 2015 08:49:12 +0100 Subject: Rename CI lint specs file --- spec/features/ci_lint_spec.rb | 39 +++++++++++++++++++++++++++++++++++++++ spec/features/lint_spec.rb | 39 --------------------------------------- 2 files changed, 39 insertions(+), 39 deletions(-) create mode 100644 spec/features/ci_lint_spec.rb delete mode 100644 spec/features/lint_spec.rb diff --git a/spec/features/ci_lint_spec.rb b/spec/features/ci_lint_spec.rb new file mode 100644 index 00000000000..441a3c702c7 --- /dev/null +++ b/spec/features/ci_lint_spec.rb @@ -0,0 +1,39 @@ +require 'spec_helper' + +describe 'CI Lint' do + before do + login_as :user + end + + describe 'YAML parsing', js: true do + before do + visit ci_lint_path + fill_in 'content', with: yaml_content + click_on 'Validate' + end + + context 'YAML is correct' do + let(:yaml_content) do + File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) + end + + it 'Yaml parsing' do + within "table" do + expect(page).to have_content('Job - rspec') + expect(page).to have_content('Job - spinach') + expect(page).to have_content('Deploy Job - staging') + expect(page).to have_content('Deploy Job - production') + end + end + end + + context 'YAML is incorrect' do + let(:yaml_content) { '' } + + it 'displays information about an error' do + expect(page).to have_content('Status: syntax is incorrect') + expect(page).to have_content('Error: Please provide content of .gitlab-ci.yml') + end + end + end +end diff --git a/spec/features/lint_spec.rb b/spec/features/lint_spec.rb deleted file mode 100644 index 441a3c702c7..00000000000 --- a/spec/features/lint_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'spec_helper' - -describe 'CI Lint' do - before do - login_as :user - end - - describe 'YAML parsing', js: true do - before do - visit ci_lint_path - fill_in 'content', with: yaml_content - click_on 'Validate' - end - - context 'YAML is correct' do - let(:yaml_content) do - File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) - end - - it 'Yaml parsing' do - within "table" do - expect(page).to have_content('Job - rspec') - expect(page).to have_content('Job - spinach') - expect(page).to have_content('Deploy Job - staging') - expect(page).to have_content('Deploy Job - production') - end - end - end - - context 'YAML is incorrect' do - let(:yaml_content) { '' } - - it 'displays information about an error' do - expect(page).to have_content('Status: syntax is incorrect') - expect(page).to have_content('Error: Please provide content of .gitlab-ci.yml') - end - end - end -end -- cgit v1.2.1 From d74b254d97e253e857a53e0320295966ac27ecff Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 22 Dec 2015 09:40:32 +0100 Subject: Make CI Lint form synchronous This removes `remote: true` from CI Lint form, making it synchronous form. This also removes some complexity related to displaying lint messages. View also has been updated, removed deprecated Bootstrap 2 tags. Improved design. Closes #4206 --- app/controllers/ci/lints_controller.rb | 4 +++- app/views/ci/lints/_create.html.haml | 2 -- app/views/ci/lints/create.js.haml | 2 -- app/views/ci/lints/show.html.haml | 36 ++++++++++++---------------------- spec/features/ci_lint_spec.rb | 2 +- 5 files changed, 17 insertions(+), 29 deletions(-) delete mode 100644 app/views/ci/lints/create.js.haml diff --git a/app/controllers/ci/lints_controller.rb b/app/controllers/ci/lints_controller.rb index 7ed78ff8e98..e782a51e7eb 100644 --- a/app/controllers/ci/lints_controller.rb +++ b/app/controllers/ci/lints_controller.rb @@ -19,8 +19,10 @@ module Ci @error = e.message @status = false rescue - @error = "Undefined error" + @error = 'Undefined error' @status = false + ensure + render :show end end end diff --git a/app/views/ci/lints/_create.html.haml b/app/views/ci/lints/_create.html.haml index 77f78caa8d8..f7875e68b7e 100644 --- a/app/views/ci/lints/_create.html.haml +++ b/app/views/ci/lints/_create.html.haml @@ -41,5 +41,3 @@ %i.fa.fa-remove.incorrect-syntax %b Error: = @error - - diff --git a/app/views/ci/lints/create.js.haml b/app/views/ci/lints/create.js.haml deleted file mode 100644 index a96c0b11b6e..00000000000 --- a/app/views/ci/lints/create.js.haml +++ /dev/null @@ -1,2 +0,0 @@ -:plain - $(".results").html("#{escape_javascript(render "create")}") \ No newline at end of file diff --git a/app/views/ci/lints/show.html.haml b/app/views/ci/lints/show.html.haml index fb9057e4882..a144c43be47 100644 --- a/app/views/ci/lints/show.html.haml +++ b/app/views/ci/lints/show.html.haml @@ -1,27 +1,17 @@ %h2 Check your .gitlab-ci.yml %hr -= form_tag ci_lint_path, method: :post, remote: true do - .control-group - = label_tag :content, "Content of .gitlab-ci.yml", class: 'control-label' - .controls - = text_area_tag :content, nil, class: 'form-control span1', rows: 7, require: true +.row + = form_tag ci_lint_path, method: :post do + .form-group + = label_tag :content, 'Content of .gitlab-ci.yml', class: 'control-label text-nowrap' + .col-sm-12 + = text_area_tag :content, nil, class: 'form-control span1', rows: 7, require: true + .col-sm-12 + .pull-left.prepend-top-10 + = submit_tag 'Validate', class: 'btn btn-success submit-yml' - .control-group.clearfix - .controls.pull-left.prepend-top-10 - = submit_tag "Validate", class: 'btn btn-success submit-yml' - - -%p.text-center.loading - %i.fa.fa-refresh.fa-spin - -.results.prepend-top-20 - -:javascript - $(".loading").hide(); - $('form').bind('ajax:beforeSend', function() { - $(".loading").show(); - }); - $('form').bind('ajax:complete', function() { - $(".loading").hide(); - }); +.row.prepend-top-20 + .col-sm-12 + .results + = render partial: 'create' if defined?(@status) diff --git a/spec/features/ci_lint_spec.rb b/spec/features/ci_lint_spec.rb index 441a3c702c7..e6e73e5e67c 100644 --- a/spec/features/ci_lint_spec.rb +++ b/spec/features/ci_lint_spec.rb @@ -5,7 +5,7 @@ describe 'CI Lint' do login_as :user end - describe 'YAML parsing', js: true do + describe 'YAML parsing' do before do visit ci_lint_path fill_in 'content', with: yaml_content -- cgit v1.2.1