diff options
Diffstat (limited to 'spec/ci/features')
-rw-r--r-- | spec/ci/features/admin/builds_spec.rb | 71 | ||||
-rw-r--r-- | spec/ci/features/admin/events_spec.rb | 20 | ||||
-rw-r--r-- | spec/ci/features/admin/projects_spec.rb | 19 | ||||
-rw-r--r-- | spec/ci/features/admin/runners_spec.rb | 63 | ||||
-rw-r--r-- | spec/ci/features/builds_spec.rb | 57 | ||||
-rw-r--r-- | spec/ci/features/commits_spec.rb | 66 | ||||
-rw-r--r-- | spec/ci/features/events_spec.rb | 20 | ||||
-rw-r--r-- | spec/ci/features/lint_spec.rb | 28 | ||||
-rw-r--r-- | spec/ci/features/projects_spec.rb | 57 | ||||
-rw-r--r-- | spec/ci/features/runners_spec.rb | 98 | ||||
-rw-r--r-- | spec/ci/features/triggers_spec.rb | 26 | ||||
-rw-r--r-- | spec/ci/features/variables_spec.rb | 26 |
12 files changed, 551 insertions, 0 deletions
diff --git a/spec/ci/features/admin/builds_spec.rb b/spec/ci/features/admin/builds_spec.rb new file mode 100644 index 00000000000..e62e83692da --- /dev/null +++ b/spec/ci/features/admin/builds_spec.rb @@ -0,0 +1,71 @@ +require 'spec_helper' + +describe "Admin Builds" do + let(:project) { FactoryGirl.create :project } + let(:commit) { FactoryGirl.create :commit, project: project } + let(:build) { FactoryGirl.create :build, commit: commit } + + before do + skip_admin_auth + login_as :user + end + + describe "GET /admin/builds" do + before do + build + visit admin_builds_path + end + + it { page.should have_content "All builds" } + it { page.should have_content build.short_sha } + end + + describe "Tabs" do + it "shows all builds" do + build = FactoryGirl.create :build, commit: commit, status: "pending" + build1 = FactoryGirl.create :build, commit: commit, status: "running" + build2 = FactoryGirl.create :build, commit: commit, status: "success" + build3 = FactoryGirl.create :build, commit: commit, status: "failed" + + visit admin_builds_path + + page.all(".build-link").size.should == 4 + end + + it "shows pending builds" do + build = FactoryGirl.create :build, commit: commit, status: "pending" + build1 = FactoryGirl.create :build, commit: commit, status: "running" + build2 = FactoryGirl.create :build, commit: commit, status: "success" + build3 = FactoryGirl.create :build, commit: commit, status: "failed" + + visit admin_builds_path + + within ".nav.nav-tabs" do + click_on "Pending" + end + + page.find(".build-link").should have_content(build.id) + page.find(".build-link").should_not have_content(build1.id) + page.find(".build-link").should_not have_content(build2.id) + page.find(".build-link").should_not have_content(build3.id) + end + + it "shows running builds" do + build = FactoryGirl.create :build, commit: commit, status: "pending" + build1 = FactoryGirl.create :build, commit: commit, status: "running" + build2 = FactoryGirl.create :build, commit: commit, status: "success" + build3 = FactoryGirl.create :build, commit: commit, status: "failed" + + visit admin_builds_path + + within ".nav.nav-tabs" do + click_on "Running" + end + + page.find(".build-link").should have_content(build1.id) + page.find(".build-link").should_not have_content(build.id) + page.find(".build-link").should_not have_content(build2.id) + page.find(".build-link").should_not have_content(build3.id) + end + end +end diff --git a/spec/ci/features/admin/events_spec.rb b/spec/ci/features/admin/events_spec.rb new file mode 100644 index 00000000000..469c6ed102d --- /dev/null +++ b/spec/ci/features/admin/events_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper' + +describe "Admin Events" do + let(:event) { FactoryGirl.create :admin_event } + + before do + skip_admin_auth + login_as :user + end + + describe "GET /admin/events" do + before do + event + visit admin_events_path + end + + it { page.should have_content "Events" } + it { page.should have_content event.description } + end +end diff --git a/spec/ci/features/admin/projects_spec.rb b/spec/ci/features/admin/projects_spec.rb new file mode 100644 index 00000000000..6f87e368deb --- /dev/null +++ b/spec/ci/features/admin/projects_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe "Admin Projects" do + let(:project) { FactoryGirl.create :project } + + before do + skip_admin_auth + login_as :user + end + + describe "GET /admin/projects" do + before do + project + visit admin_projects_path + end + + it { page.should have_content "Projects" } + end +end diff --git a/spec/ci/features/admin/runners_spec.rb b/spec/ci/features/admin/runners_spec.rb new file mode 100644 index 00000000000..2827a7fc6e5 --- /dev/null +++ b/spec/ci/features/admin/runners_spec.rb @@ -0,0 +1,63 @@ +require 'spec_helper' + +describe "Admin Runners" do + before do + skip_admin_auth + login_as :user + end + + describe "Runners page" do + before do + runner = FactoryGirl.create(:runner) + commit = FactoryGirl.create(:commit) + FactoryGirl.create(:build, commit: commit, runner_id: runner.id) + visit admin_runners_path + end + + it { page.has_text? "Manage Runners" } + it { page.has_text? "To register a new runner" } + it { page.has_text? "Runners with last contact less than a minute ago: 1" } + + describe 'search' do + before do + FactoryGirl.create :runner, description: 'foo' + FactoryGirl.create :runner, description: 'bar' + + fill_in 'search', with: 'foo' + click_button 'Search' + end + + it { page.should have_content("foo") } + it { page.should_not have_content("bar") } + end + end + + describe "Runner show page" do + let(:runner) { FactoryGirl.create :runner } + + before do + FactoryGirl.create(:project, name: "foo") + FactoryGirl.create(:project, name: "bar") + visit admin_runner_path(runner) + end + + describe 'runner info' do + it { find_field('runner_token').value.should eq runner.token } + end + + describe 'projects' do + it { page.should have_content("foo") } + it { page.should have_content("bar") } + end + + describe 'search' do + before do + fill_in 'search', with: 'foo' + click_button 'Search' + end + + it { page.should have_content("foo") } + it { page.should_not have_content("bar") } + end + end +end diff --git a/spec/ci/features/builds_spec.rb b/spec/ci/features/builds_spec.rb new file mode 100644 index 00000000000..fcd7996efd7 --- /dev/null +++ b/spec/ci/features/builds_spec.rb @@ -0,0 +1,57 @@ +require 'spec_helper' + +describe "Builds" do + before do + @project = FactoryGirl.create :project + @commit = FactoryGirl.create :commit, project: @project + @build = FactoryGirl.create :build, commit: @commit + end + + describe "GET /:project/builds/:id" do + before do + login_as :user + visit project_build_path(@project, @build) + end + + it { page.should have_content @commit.sha[0..7] } + it { page.should have_content @commit.git_commit_message } + it { page.should have_content @commit.git_author_name } + end + + describe "GET /:project/builds/:id/cancel" do + before do + login_as :user + @build.run! + visit cancel_project_build_path(@project, @build) + end + + it { page.should have_content 'canceled' } + it { page.should have_content 'Retry' } + end + + describe "POST /:project/builds/:id/retry" do + before do + login_as :user + @build.cancel! + visit project_build_path(@project, @build) + click_link 'Retry' + end + + it { page.should have_content 'pending' } + it { page.should have_content 'Cancel' } + end + + describe "Show page public accessible" do + before do + @project = FactoryGirl.create :public_project + @commit = FactoryGirl.create :commit, project: @project + @runner = FactoryGirl.create :specific_runner + @build = FactoryGirl.create :build, commit: @commit, runner: @runner + + stub_gitlab_calls + visit project_build_path(@project, @build) + end + + it { page.should have_content @commit.sha[0..7] } + end +end diff --git a/spec/ci/features/commits_spec.rb b/spec/ci/features/commits_spec.rb new file mode 100644 index 00000000000..202f05c516f --- /dev/null +++ b/spec/ci/features/commits_spec.rb @@ -0,0 +1,66 @@ +require 'spec_helper' + +describe "Commits" do + context "Authenticated user" do + before do + login_as :user + @project = FactoryGirl.create :project + @commit = FactoryGirl.create :commit, project: @project + @build = FactoryGirl.create :build, commit: @commit + end + + describe "GET /:project/commits/:sha" do + before do + visit project_ref_commit_path(@project, @commit.ref, @commit.sha) + end + + it { page.should have_content @commit.sha[0..7] } + it { page.should have_content @commit.git_commit_message } + it { page.should have_content @commit.git_author_name } + end + + describe "Cancel commit" do + it "cancels commit" do + visit project_ref_commit_path(@project, @commit.ref, @commit.sha) + click_on "Cancel" + + page.should have_content "canceled" + end + end + + describe ".gitlab-ci.yml not found warning" do + it "does not show warning" do + visit project_ref_commit_path(@project, @commit.ref, @commit.sha) + + page.should_not have_content ".gitlab-ci.yml not found in this commit" + end + + it "shows warning" do + @commit.push_data[:ci_yaml_file] = nil + @commit.save + + visit project_ref_commit_path(@project, @commit.ref, @commit.sha) + + page.should have_content ".gitlab-ci.yml not found in this commit" + end + end + end + + context "Public pages" do + before do + @project = FactoryGirl.create :public_project + @commit = FactoryGirl.create :commit, project: @project + @build = FactoryGirl.create :build, commit: @commit + end + + describe "GET /:project/commits/:sha" do + before do + visit project_ref_commit_path(@project, @commit.ref, @commit.sha) + end + + it { page.should have_content @commit.sha[0..7] } + it { page.should have_content @commit.git_commit_message } + it { page.should have_content @commit.git_author_name } + end + end +end diff --git a/spec/ci/features/events_spec.rb b/spec/ci/features/events_spec.rb new file mode 100644 index 00000000000..77d1fba5769 --- /dev/null +++ b/spec/ci/features/events_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper' + +describe "Events" do + let(:project) { FactoryGirl.create :project } + let(:event) { FactoryGirl.create :admin_event, project: project } + + before do + login_as :user + end + + describe "GET /project/:id/events" do + before do + event + visit project_events_path(project) + end + + it { page.should have_content "Events" } + it { page.should have_content event.description } + end +end diff --git a/spec/ci/features/lint_spec.rb b/spec/ci/features/lint_spec.rb new file mode 100644 index 00000000000..0b3d4e099fb --- /dev/null +++ b/spec/ci/features/lint_spec.rb @@ -0,0 +1,28 @@ +require 'spec_helper' + +describe "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 lint_path + fill_in "content", with: content + click_on "Validate" + within "table" do + page.should have_content("Job - rspec") + page.should have_content("Job - spinach") + page.should have_content("Deploy Job - staging") + page.should have_content("Deploy Job - production") + end + end + + it "Yaml parsing with error", js: true do + visit lint_path + fill_in "content", with: "" + click_on "Validate" + page.should have_content("Status: syntax is incorrect") + page.should have_content("Error: Please provide content of .gitlab-ci.yml") + end +end diff --git a/spec/ci/features/projects_spec.rb b/spec/ci/features/projects_spec.rb new file mode 100644 index 00000000000..3f21af92a2b --- /dev/null +++ b/spec/ci/features/projects_spec.rb @@ -0,0 +1,57 @@ +require 'spec_helper' + +describe "Projects" do + before do + login_as :user + @project = FactoryGirl.create :project, name: "GitLab / gitlab-shell" + end + + describe "GET /projects", js: true do + before do + stub_js_gitlab_calls + visit projects_path + end + + it { page.should have_content "GitLab / gitlab-shell" } + it { page.should have_selector ".search input#search" } + end + + describe "GET /projects/:id" do + before do + visit project_path(@project) + end + + it { page.should have_content @project.name } + it { page.should have_content 'All commits' } + end + + describe "GET /projects/:id/edit" do + before do + visit edit_project_path(@project) + end + + it { page.should have_content @project.name } + it { page.should have_content 'Build Schedule' } + + it "updates configuration" do + fill_in 'Timeout', with: '70' + click_button 'Save changes' + + page.should have_content 'was successfully updated' + + find_field('Timeout').value.should eq '70' + end + end + + describe "GET /projects/:id/charts" do + before do + visit project_charts_path(@project) + end + + it { page.should have_content 'Overall' } + it { page.should have_content 'Builds chart for last week' } + it { page.should have_content 'Builds chart for last month' } + it { page.should have_content 'Builds chart for last year' } + it { page.should have_content 'Commit duration in minutes for last 30 commits' } + end +end diff --git a/spec/ci/features/runners_spec.rb b/spec/ci/features/runners_spec.rb new file mode 100644 index 00000000000..c41dc5b2e2e --- /dev/null +++ b/spec/ci/features/runners_spec.rb @@ -0,0 +1,98 @@ +require 'spec_helper' + +describe "Runners" do + before do + login_as :user + end + + describe "specific runners" do + before do + @project = FactoryGirl.create :project + @project2 = FactoryGirl.create :project + stub_js_gitlab_calls + + # all projects should be authorized for user + Network.any_instance.stub(:projects).and_return([ + OpenStruct.new({id: @project.gitlab_id}), + OpenStruct.new({id: @project2.gitlab_id}) + ]) + + @shared_runner = FactoryGirl.create :shared_runner + @specific_runner = FactoryGirl.create :specific_runner + @specific_runner2 = FactoryGirl.create :specific_runner + @project.runners << @specific_runner + @project2.runners << @specific_runner2 + end + + it "places runners in right places" do + visit project_runners_path(@project) + page.find(".available-specific-runners").should have_content(@specific_runner2.display_name) + page.find(".activated-specific-runners").should have_content(@specific_runner.display_name) + page.find(".available-shared-runners").should have_content(@shared_runner.display_name) + end + + it "enables specific runner for project" do + visit project_runners_path(@project) + + within ".available-specific-runners" do + click_on "Enable for this project" + end + + page.find(".activated-specific-runners").should have_content(@specific_runner2.display_name) + end + + it "disables specific runner for project" do + @project2.runners << @specific_runner + + visit project_runners_path(@project) + + within ".activated-specific-runners" do + click_on "Disable for this project" + end + + page.find(".available-specific-runners").should have_content(@specific_runner.display_name) + end + + it "removes specific runner for project if this is last project for that runners" do + visit project_runners_path(@project) + + within ".activated-specific-runners" do + click_on "Remove runner" + end + + Runner.exists?(id: @specific_runner).should be_false + end + end + + describe "shared runners" do + before do + @project = FactoryGirl.create :project + stub_js_gitlab_calls + end + + it "enables shared runners" do + visit project_runners_path(@project) + + click_on "Enable shared runners" + + @project.reload.shared_runners_enabled.should be_true + end + end + + describe "show page" do + before do + @project = FactoryGirl.create :project + stub_js_gitlab_calls + @specific_runner = FactoryGirl.create :specific_runner + @project.runners << @specific_runner + end + + it "shows runner information" do + visit project_runners_path(@project) + + click_on @specific_runner.short_sha + + page.should have_content(@specific_runner.platform) + end + end +end diff --git a/spec/ci/features/triggers_spec.rb b/spec/ci/features/triggers_spec.rb new file mode 100644 index 00000000000..2076429383d --- /dev/null +++ b/spec/ci/features/triggers_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe 'Variables' do + before do + login_as :user + @project = FactoryGirl.create :project + stub_js_gitlab_calls + visit project_triggers_path(@project) + end + + context 'create a trigger' do + before do + click_on 'Add Trigger' + @project.triggers.count.should == 1 + end + + it 'contains trigger token' do + page.should have_content(@project.triggers.first.token) + end + + it 'revokes the trigger' do + click_on 'Revoke' + @project.triggers.count.should == 0 + end + end +end diff --git a/spec/ci/features/variables_spec.rb b/spec/ci/features/variables_spec.rb new file mode 100644 index 00000000000..2bb0d9dedde --- /dev/null +++ b/spec/ci/features/variables_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe "Variables" do + before do + login_as :user + end + + describe "specific runners" do + before do + @project = FactoryGirl.create :project + stub_js_gitlab_calls + end + + it "creates variable", js: true do + visit project_variables_path(@project) + click_on "Add a variable" + fill_in "Key", with: "SECRET_KEY" + fill_in "Value", with: "SECRET_VALUE" + click_on "Save changes" + + page.should have_content("Variables were successfully updated.") + @project.variables.count.should == 1 + end + + end +end |