From 93f49489e416d01af75ced43c2b89c8735d33fed Mon Sep 17 00:00:00 2001 From: Jan-Willem van der Meer Date: Mon, 11 Aug 2014 17:57:29 +0200 Subject: [PATCH 1/7] Add transition id to database --- ...dd_jira_issue_transition_id_to_services.rb | 11 +++++ db/schema.rb | 40 ++++++++++--------- 2 files changed, 32 insertions(+), 19 deletions(-) create mode 100644 db/migrate/20140811155127_add_jira_issue_transition_id_to_services.rb diff --git a/db/migrate/20140811155127_add_jira_issue_transition_id_to_services.rb b/db/migrate/20140811155127_add_jira_issue_transition_id_to_services.rb new file mode 100644 index 0000000000..c687804fbe --- /dev/null +++ b/db/migrate/20140811155127_add_jira_issue_transition_id_to_services.rb @@ -0,0 +1,11 @@ +class AddJiraIssueTransitionIdToServices < ActiveRecord::Migration + def up + add_column :services, :jira_issue_transition_id, :string, default: '2' + Service.reset_column_information + Service.where(jira_issue_transition_id: nil).update_all jira_issue_transition_id: '2' + end + + def down + remove_column :services, :jira_issue_transition_id + end +end diff --git a/db/schema.rb b/db/schema.rb index bdf35c8945..c05897a8b7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140611135229) do +ActiveRecord::Schema.define(version: 20140811155127) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -273,10 +273,10 @@ ActiveRecord::Schema.define(version: 20140611135229) do t.string "type" t.string "title" t.string "token" - t.integer "project_id", null: false + t.integer "project_id", null: false t.datetime "created_at" t.datetime "updated_at" - t.boolean "active", default: false, null: false + t.boolean "active", default: false, null: false t.string "project_url" t.string "subdomain" t.string "room" @@ -285,6 +285,7 @@ ActiveRecord::Schema.define(version: 20140611135229) do t.string "username" t.string "password" t.string "api_version" + t.string "jira_issue_transition_id", default: "2" end add_index "services", ["project_id"], name: "index_services_on_project_id", using: :btree @@ -325,12 +326,12 @@ ActiveRecord::Schema.define(version: 20140611135229) do end create_table "users", force: true do |t| - t.string "email", default: "", null: false - t.string "encrypted_password", default: "", null: false + t.string "email", default: "", null: false + t.string "encrypted_password", default: "", null: false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0 + t.integer "sign_in_count", default: 0 t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" @@ -338,24 +339,24 @@ ActiveRecord::Schema.define(version: 20140611135229) do t.datetime "created_at" t.datetime "updated_at" t.string "name" - t.boolean "admin", default: false, null: false - t.integer "projects_limit", default: 10 - t.string "skype", default: "", null: false - t.string "linkedin", default: "", null: false - t.string "twitter", default: "", null: false + t.boolean "admin", default: false, null: false + t.integer "projects_limit", default: 10 + t.string "skype", default: "", null: false + t.string "linkedin", default: "", null: false + t.string "twitter", default: "", null: false t.string "authentication_token" - t.integer "theme_id", default: 1, null: false + t.integer "theme_id", default: 1, null: false t.string "bio" - t.integer "failed_attempts", default: 0 + t.integer "failed_attempts", default: 0 t.datetime "locked_at" t.string "extern_uid" t.string "provider" t.string "username" - t.boolean "can_create_group", default: true, null: false - t.boolean "can_create_team", default: true, null: false + t.boolean "can_create_group", default: true, null: false + t.boolean "can_create_team", default: true, null: false t.string "state" - t.integer "color_scheme_id", default: 1, null: false - t.integer "notification_level", default: 1, null: false + t.integer "color_scheme_id", default: 1, null: false + t.integer "notification_level", default: 1, null: false t.datetime "password_expires_at" t.integer "created_by_id" t.datetime "last_credential_check_at" @@ -364,8 +365,9 @@ ActiveRecord::Schema.define(version: 20140611135229) do t.datetime "confirmed_at" t.datetime "confirmation_sent_at" t.string "unconfirmed_email" - t.boolean "hide_no_ssh_key", default: false - t.string "website_url", default: "", null: false + t.boolean "hide_no_ssh_key", default: false + t.string "website_url", default: "", null: false + t.datetime "admin_email_unsubscribed_at" end add_index "users", ["admin"], name: "index_users_on_admin", using: :btree From d048dc26c5f310eb774cd988b76e096c0e7ed4ca Mon Sep 17 00:00:00 2001 From: Jan-Willem van der Meer Date: Mon, 11 Aug 2014 19:25:08 +0200 Subject: [PATCH 2/7] Add jira issue transition id to service form --- app/models/project_services/jira_service.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/project_services/jira_service.rb b/app/models/project_services/jira_service.rb index 96faea5536..ec6d312cf3 100644 --- a/app/models/project_services/jira_service.rb +++ b/app/models/project_services/jira_service.rb @@ -42,7 +42,8 @@ class JiraService < Service { type: 'text', name: 'project_url', placeholder: 'Url to JIRA, http://jira.example' }, { type: 'text', name: 'username', placeholder: '' }, { type: 'password', name: 'password', placeholder: '' }, - { type: 'text', name: 'api_version', placeholder: '2' } + { type: 'text', name: 'api_version', placeholder: '2' }, + { type: 'text', name: 'jira_issue_transition_id', placeholder: '2' } ] end From 53d5024b8672a7472d43591f6b59310e256d6d59 Mon Sep 17 00:00:00 2001 From: Jan-Willem van der Meer Date: Mon, 11 Aug 2014 19:25:31 +0200 Subject: [PATCH 3/7] Add custom jira-issue-transition-id to request --- app/models/project_services/jira_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/project_services/jira_service.rb b/app/models/project_services/jira_service.rb index ec6d312cf3..594472bd82 100644 --- a/app/models/project_services/jira_service.rb +++ b/app/models/project_services/jira_service.rb @@ -70,7 +70,7 @@ class JiraService < Service }] }, 'transition' => { - 'id' => '2' + 'id' => jira_issue_transition_id } } From fc16223c8159a9e83cfb95174a8973dc780c9d29 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 12 Aug 2014 10:33:27 +0300 Subject: [PATCH 4/7] Show group ldap settings on admin/group page Signed-off-by: Dmitriy Zaporozhets --- app/views/admin/groups/show.html.haml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/app/views/admin/groups/show.html.haml b/app/views/admin/groups/show.html.haml index a662984969..20bbd29613 100644 --- a/app/views/admin/groups/show.html.haml +++ b/app/views/admin/groups/show.html.haml @@ -31,6 +31,17 @@ %strong = @group.created_at.stamp("March 1, 1999") + - if @group.ldap_cn.present? + %li + %span.light LDAP group cn: + %strong + = @group.ldap_cn + + %li + %span.light LDAP access level: + %strong + = @group.human_ldap_access + .panel.panel-default .panel-heading %h3.panel-title @@ -50,11 +61,11 @@ = paginate @projects, param_name: 'projects_page', theme: 'gitlab' - if @group.shared_projects.any? - .ui-box - .title + .panel.panel-default + .panel-heading Projects shared with #{@group.name} - %small - (#{@group.shared_projects.count}) + %span.badge + #{@group.shared_projects.count} %ul.well-list - @group.shared_projects.sort_by(&:name).each do |project| %li From ced5d5177a7b6dab017e49da578aa20b61a3aec1 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 12 Aug 2014 10:45:20 +0300 Subject: [PATCH 5/7] Show ldap notice on group member page Signed-off-by: Dmitriy Zaporozhets --- app/views/groups/members.html.haml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/views/groups/members.html.haml b/app/views/groups/members.html.haml index 6e3b462b75..b09d600c6d 100644 --- a/app/views/groups/members.html.haml +++ b/app/views/groups/members.html.haml @@ -18,7 +18,7 @@ - if current_user && current_user.can?(:manage_group, @group) .pull-right - if ldap_enabled? && @group.ldap_cn.present? - = link_to reset_access_group_ldap_path(@group), class: 'btn grouped', data: { confirm: "Reset the access level of all other LDAP group team members to '#{@group.human_ldap_access}'?" }, method: :put do + = link_to reset_access_group_ldap_path(@group), class: 'btn btn-grouped', data: { confirm: "Reset the access level of all other LDAP group team members to '#{@group.human_ldap_access}'?" }, method: :put do Reset access = link_to '#', class: 'btn btn-new js-toggle-button' do @@ -28,6 +28,13 @@ .js-toggle-content.hide.new-group-member-holder = render "new_group_member" +- if ldap_enabled? && @group.ldap_cn.present? + .bs-callout.bs-callout-info + This group sync members from LDAP group with cn + %code #{@group.ldap_cn} + and give them access level + %code #{@group.human_ldap_access} + .panel.panel-default.prepend-top-20 .panel-heading %strong #{@group.name} From 196921e5fce47c58ddd2df957328341b38bf7730 Mon Sep 17 00:00:00 2001 From: Jan-Willem van der Meer Date: Tue, 12 Aug 2014 09:54:43 +0200 Subject: [PATCH 6/7] Add test for jira_issue_transition_id --- spec/models/jira_service_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/models/jira_service_spec.rb b/spec/models/jira_service_spec.rb index e1b2a91b78..ae81531c86 100644 --- a/spec/models/jira_service_spec.rb +++ b/spec/models/jira_service_spec.rb @@ -55,5 +55,13 @@ describe JiraService, models: true do body: /Issue solved with/ ).once end + + it "calls the api with jira_issue_transition_id" do + @jira_service.jira_issue_transition_id = 'this-is-a-custom-id' + @jira_service.execute(@sample_data, JiraIssue.new("JIRA-123")) + WebMock.should have_requested(:post, @api_url).with( + body: /this-is-a-custom-id/ + ).once + end end end From 471e183f8aefbbcf9f83386217030f6775bbc134 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 12 Aug 2014 08:02:20 +0000 Subject: [PATCH 7/7] Better ldap info sentence --- app/views/groups/members.html.haml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/views/groups/members.html.haml b/app/views/groups/members.html.haml index b09d600c6d..d00397c26a 100644 --- a/app/views/groups/members.html.haml +++ b/app/views/groups/members.html.haml @@ -30,11 +30,12 @@ - if ldap_enabled? && @group.ldap_cn.present? .bs-callout.bs-callout-info - This group sync members from LDAP group with cn + The members of this group are synced with the LDAP group with cn %code #{@group.ldap_cn} - and give them access level + \. They are given %code #{@group.human_ldap_access} - + access. + .panel.panel-default.prepend-top-20 .panel-heading %strong #{@group.name}