diff options
-rw-r--r-- | CHANGELOG | 3 | ||||
-rw-r--r-- | app/controllers/variables_controller.rb | 16 | ||||
-rw-r--r-- | app/models/variable.rb | 2 | ||||
-rw-r--r-- | app/views/layouts/_nav_admin.html.haml | 2 | ||||
-rw-r--r-- | app/views/layouts/_nav_project.html.haml | 2 | ||||
-rw-r--r-- | app/views/variables/show.html.haml (renamed from app/views/variables/index.html.haml) | 2 | ||||
-rw-r--r-- | config/routes.rb | 2 | ||||
-rw-r--r-- | doc/README.md | 3 | ||||
-rw-r--r-- | doc/examples/README.md | 1 | ||||
-rw-r--r-- | doc/examples/test-clojure-application.md | 35 | ||||
-rw-r--r-- | spec/features/variables_spec.rb | 2 |
11 files changed, 62 insertions, 8 deletions
@@ -13,8 +13,11 @@ v7.14.0 (unreleased) - Fix broken yaml error saving - Add committed_at to commits to properly order last commit (the force push issue) - Rename type(s) to stage(s) + - Fix navigation icons - Add missing stage when doing retry - Require variable keys to be not-empty and unique + - Fix variable saving issue + - Display variable saving errors in variables page not the project's - Added Build Triggers API v7.13.1 diff --git a/app/controllers/variables_controller.rb b/app/controllers/variables_controller.rb index 6eb908e..00f60f3 100644 --- a/app/controllers/variables_controller.rb +++ b/app/controllers/variables_controller.rb @@ -6,7 +6,17 @@ class VariablesController < ApplicationController layout 'project' - def index + def show + end + + def update + if project.update_attributes(project_params) + EventService.new.change_project_settings(current_user, project) + + redirect_to project_variables_path(project), notice: 'Variables were successfully updated.' + else + render action: 'show' + end end private @@ -14,4 +24,8 @@ class VariablesController < ApplicationController def project @project ||= Project.find(params[:project_id]) end + + def project_params + params.require(:project).permit({ variables_attributes: [:id, :key, :value, :_destroy] }) + end end diff --git a/app/models/variable.rb b/app/models/variable.rb index 559b9f2..c084b89 100644 --- a/app/models/variable.rb +++ b/app/models/variable.rb @@ -15,7 +15,7 @@ class Variable < ActiveRecord::Base belongs_to :project validates_presence_of :key - validates_uniqueness_of :key + validates_uniqueness_of :key, scope: :project_id attr_encrypted :value, mode: :per_attribute_iv_and_salt, key: GitlabCi::Application.secrets.db_key_base end diff --git a/app/views/layouts/_nav_admin.html.haml b/app/views/layouts/_nav_admin.html.haml index 94b5468..412659a 100644 --- a/app/views/layouts/_nav_admin.html.haml +++ b/app/views/layouts/_nav_admin.html.haml @@ -5,7 +5,7 @@ Projects = nav_link path: 'events' do = link_to admin_events_path do - %i.icon-bar-chart + %i.icon-book Events = nav_link path: 'runners#index' do = link_to admin_runners_path do diff --git a/app/views/layouts/_nav_project.html.haml b/app/views/layouts/_nav_project.html.haml index 7f7f00e..dbcdc40 100644 --- a/app/views/layouts/_nav_project.html.haml +++ b/app/views/layouts/_nav_project.html.haml @@ -26,7 +26,7 @@ Triggers = nav_link path: 'services#index' do = link_to project_services_path(@project) do - %i.icon-gear + %i.icon-share Services = nav_link path: 'events#index' do = link_to project_events_path(@project) do diff --git a/app/views/variables/index.html.haml b/app/views/variables/show.html.haml index 64a4451..e296e17 100644 --- a/app/views/variables/index.html.haml +++ b/app/views/variables/show.html.haml @@ -7,7 +7,7 @@ %hr -= nested_form_for @project, html: { class: 'form-horizontal' } do |f| += nested_form_for @project, url: url_for(controller: 'variables', action: 'update'), html: { class: 'form-horizontal' } do |f| - if @project.errors.any? #error_explanation %p.lead= "#{pluralize(@project.errors.count, "error")} prohibited this project from being saved:" diff --git a/config/routes.rb b/config/routes.rb index 8fdcf95..cbb5231 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -68,7 +68,7 @@ Rails.application.routes.draw do resources :runner_projects, only: [:create, :destroy] resources :events, only: [:index] - resources :variables, only: [:index] + resource :variables, only: [:show, :update] end resource :user_sessions do diff --git a/doc/README.md b/doc/README.md index 0a84103..e3534c6 100644 --- a/doc/README.md +++ b/doc/README.md @@ -14,6 +14,7 @@ + [Test and deploy Ruby applications to Heroku](examples/test-and-deploy-ruby-application-to-heroku.md) + [Test and deploy Python applications to Heroku](examples/test-and-deploy-python-application-to-heroku.md) ++ [Test Clojure applications](examples/test-clojure-application.md) + Help your favorite programming language and GitLab by sending a merge request with a guide for that language. ### Administrator documentation @@ -23,4 +24,4 @@ + [User permissions](permissions/README.md) + [Backup/Restore](raketasks/backup_restore.md) + [Migrating to packaged CI](migration_to_omnibus/README.md) -+ [API](api/README.md)
\ No newline at end of file ++ [API](api/README.md) diff --git a/doc/examples/README.md b/doc/examples/README.md index 78dc1e0..e0b9fa0 100644 --- a/doc/examples/README.md +++ b/doc/examples/README.md @@ -2,3 +2,4 @@ + [Test and deploy Ruby Application to Heroku](test-and-deploy-ruby-application-to-heroku.md) + [Test and deploy Python Application to Heroku](test-and-deploy-python-application-to-heroku.md) ++ [Test Clojure applications](examples/test-clojure-application.md) diff --git a/doc/examples/test-clojure-application.md b/doc/examples/test-clojure-application.md new file mode 100644 index 0000000..6c6faf8 --- /dev/null +++ b/doc/examples/test-clojure-application.md @@ -0,0 +1,35 @@ +## Test Clojure applications + +This example will guide you how to run tests in your Clojure application. + +You can checkout the example [source](https://gitlab.com/dzaporozhets/clojure-web-application) and check [CI status](https://ci.gitlab.com/projects/6306). + +### Configure project + +This is what the `.gitlab-ci.yml` file looks like for this project: + +```yaml +variables: + POSTGRES_DB: sample-test + DATABASE_URL: "postgresql://postgres@postgres:5432/sample-test" + +before_script: + - apt-get update -y + - apt-get install default-jre postgresql-client -y + - wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein + - chmod a+x lein + - export LEIN_ROOT=1 + - PATH=$PATH:. + - lein deps + - lein migratus migrate + +test: + script: + - lein test +``` + +In before script we install JRE and [Leiningen](http://leiningen.org/). +Sample project uses [migratus](https://github.com/yogthos/migratus) library to manage database migrations. +So we added database migration as last step of `before_script` section + +You can use public runners available on `ci.gitlab.com` for testing your application with such configuration. diff --git a/spec/features/variables_spec.rb b/spec/features/variables_spec.rb index 21a7a11..2bb0d9d 100644 --- a/spec/features/variables_spec.rb +++ b/spec/features/variables_spec.rb @@ -18,7 +18,7 @@ describe "Variables" do fill_in "Value", with: "SECRET_VALUE" click_on "Save changes" - page.should have_content("Project was successfully updated.") + page.should have_content("Variables were successfully updated.") @project.variables.count.should == 1 end |