Skip to content
This repository has been archived by the owner on Jan 23, 2021. It is now read-only.

Commit

Permalink
Merge pull request #178 from akiko-pusu/develop
Browse files Browse the repository at this point in the history
Release v0.1.9.
  • Loading branch information
akiko-pusu authored Apr 3, 2018
2 parents dff53c7 + 1266b86 commit 26f9aff
Show file tree
Hide file tree
Showing 44 changed files with 378 additions and 206 deletions.
77 changes: 77 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
#
version: 2

general:
artifacts:
- coverage/${CIRCLE_PROJECT_REPONAME}_test/index.html

jobs:
build:
docker:
# specify the version you desire here (ruby 2.4.x)
- image: circleci/ruby:2.4-node-browsers
steps:
- checkout

test:
docker:
# specify the version you desire here
- image: circleci/ruby:2.4-node-browsers
environment:
RAILS_ENV: test
DB_HOST: 127.0.0.1
DRIVER: headless
TZ: /usr/share/zoneinfo/Asia/Tokyo
- image: mysql:5.7
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_bin --innodb-large-prefix=true --innodb-file-format=Barracuda --sql-mode=""
environment:
MYSQL_USER: root
MYSQL_ALLOW_EMPTY_PASSWORD: yes

working_directory: ~/repo
steps:
- checkout
- run:
name: ready for redmine
command: |
REDMINE_BRANCH=3.4-stable sh script/circleci-setup.sh
- run: bundle install --path vendor/bundle --without postgresql rmagick && bundle update
- run: bundle exec rake db:create RAILS_ENV=test
- run: bundle exec rake db:migrate RAILS_ENV=test
- run: bundle exec rake redmine:plugins:migrate RAILS_ENV=test
- run:
command: |
bundle exec rake ${CIRCLE_PROJECT_REPONAME}:test RAILS_ENV=test
- run:
command: |
bundle exec rspec -I plugins/${CIRCLE_PROJECT_REPONAME}/spec --format documentation \
plugins/redmine_issue_templates/spec/
- run:
command: |
bundle exec rake redmine:plugins:migrate NAME=${CIRCLE_PROJECT_REPONAME} \
VERSION=0 RAILS_ENV=test
- run:
command: |
mkdir -p /tmp/coverage
cp -r coverage/${CIRCLE_PROJECT_REPONAME}_test /tmp/coverage/
cp -r coverage/${CIRCLE_PROJECT_REPONAME}_spec /tmp/coverage/
- store_artifacts:
path: /tmp/coverage

workflows:
version: 2
build_and_test:
jobs:
- build
- test:
requires:
- build
filters:
branches:
ignore:
- support-rails5
- /trunk-.*/
3 changes: 1 addition & 2 deletions Gemfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ group :test do
#
gem 'shoulda', require: false
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'factory_bot_rails'
gem 'capybara'
gem 'launchy'
gem 'poltergeist', require: false
gem 'database_cleaner'
end
25 changes: 19 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Plugin to generate and use issue templates for each project to assist issue
creation. For Redmine 2.1.x or higher, please use version 0.0.4 or higher. For
Redmine 2.0, please use version 0.0.3 or higher.

Build Status: [![wercker status](https://app.wercker.com/status/1782a97bc897492cead97ebdbe298755/s/master "wercker status")](https://app.wercker.com/project/byKey/1782a97bc897492cead97ebdbe298755)
Build Status: [![CircleCI](https://circleci.com/gh/akiko-pusu/redmine_issue_templates.svg?style=svg)](https://circleci.com/gh/akiko-pusu/redmine_issue_templates)

### Repository

Expand Down Expand Up @@ -74,12 +74,25 @@ some trouble related "bundle intall", please try --without option.

## Changelog

### 0.1.9

Bugfix and refactoring release.

* Bugfix: Fix wrong template sort ordering. (GitHub: #174)
* Change UI to reorder templates with using drag and drop.
* Add feature to copy template (Now project scope template only.)
* Code refactoring. Use Headless Chrome for feature spec. Change to use CircleCI for build and test.
* PR: Update Bulgarian translation. Thank you so much, Ivan Cenov! (GitHub: #171)
* PR: Update Update pt-BR.yml Thank you so much, Adriano Baptistella! (GitHub: #173)
* Bugfix: Wrong column label in "Preview Template Contents" modal dialog. (GitHub: #154)
* PR: Updates to German language file. Thank you so much, Tobias Fischer! (GitHub: #164)

### 0.1.8

Bugfix release.

* Bugfix: Prevent "undefined local variable or method" error when listing project orphaned templates. (GitHub: #150)
* PR: Add Portuguese translation. Thank you so much, Adriano Baptistella! (GitHub: #149)
* PR: Add Portuguese translation. Thank you so much, Adriano Baptistella! (GitHub: #149)
* Change url of Redmine Plugin Directory. (Changed identifier from issue_templates to redmine_issue_templates.)


Expand Down Expand Up @@ -351,12 +364,12 @@ Please see wercker.yml for more details.
% cp plugins/redmine_issue_templates/Gemfile.local plugins/redmine_issue_templates/Gemfile
% bundle install --with test
% export RAILS_ENV=test
% bundle exec rake redmine_issue_templates:spec
% bundle exec rspec -I plugins/redmine_issue_templates/spec --format documentation plugins/redmine_issue_templates/spec/

By default, use poltergeist as a webdriver. If you set environment variable
'DRIVER' to 'selenium', selenium-webdriver is used.
By default, use chrome as a webdriver. If you set environment variable
'DRIVER' to 'headless', headless_chrome is used.

% bundle exec rake redmine_issue_templates:spec DRIVER='selenium'
% bundle exec rspec -I plugins/redmine_issue_templates/spec --format documentation plugins/redmine_issue_templates/spec/ DRIVER='headless'

### License

Expand Down
7 changes: 0 additions & 7 deletions app/controllers/concerns/issue_templates_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ def log_action
end
end

def render_for_move_with_format
respond_to do |format|
format.html { redirect_to action: 'index' }
format.xml { head :ok }
end
end

def plugin_setting
@plugin_setting ||= Setting.plugin_redmine_issue_templates
end
Expand Down
30 changes: 16 additions & 14 deletions app/controllers/global_issue_templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class GlobalIssueTemplatesController < ApplicationController
include IssuesHelper
include Concerns::IssueTemplatesCommon
menu_item :issues
before_filter :find_object, only: [:show, :edit, :destroy]
before_filter :find_project, only: [:edit]
before_filter :find_object, only: [:show, :edit, :update, :destroy]
before_filter :find_project, only: [:edit, :update]
before_filter :require_admin, only: [:index, :new, :show], excep: [:preview]

#
Expand All @@ -18,7 +18,7 @@ def index
template_map = {}
trackers.each do |tracker|
tracker_id = tracker.id
templates = GlobalIssueTemplate.search_by_tracker(tracker_id).order_by_position
templates = GlobalIssueTemplate.search_by_tracker(tracker_id).sorted
template_map[Tracker.find(tracker_id)] = templates if templates.any?
end
render layout: !request.xhr?, locals: { template_map: template_map, trackers: trackers }
Expand All @@ -44,6 +44,12 @@ def show
render_form
end

def update
@global_issue_template.safe_attributes = template_params
@global_issue_template.checklist_json = checklists.to_json
save_and_flash(:notice_successful_update)
end

def edit
# Change from request.post to request.patch for Rails4.
return unless request.patch? || request.put?
Expand Down Expand Up @@ -72,10 +78,6 @@ def preview
render partial: 'common/preview'
end

def move
move_order(params[:to])
end

def orphaned_templates
orphaned = GlobalIssueTemplate.orphaned
render partial: 'orphaned_templates', locals: { orphaned_templates: orphaned }
Expand All @@ -93,15 +95,15 @@ def find_object
render_404
end

def move_order(method)
GlobalIssueTemplate.find(params[:id]).send "move_#{method}"
render_for_move_with_format
end

def save_and_flash(message)
return unless @global_issue_template.save
flash[:notice] = l(message)
redirect_to action: 'show', id: @global_issue_template.id
respond_to do |format|
format.html do
flash[:notice] = l(message)
redirect_to action: 'show', id: @global_issue_template.id
end
format.js { head 200 }
end
end

def template_params
Expand Down
41 changes: 23 additions & 18 deletions app/controllers/issue_templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ class IssueTemplatesController < ApplicationController
include IssuesHelper
include Concerns::IssueTemplatesCommon
menu_item :issues
before_filter :find_object, only: [:show, :edit, :destroy]
before_filter :find_user, :find_project, :authorize,
except: [:preview, :move_order_higher, :move_order_lower, :move_order_to_top, :move_order_to_bottom, :move]
before_filter :find_object, only: [:show, :edit, :update, :destroy]
before_filter :find_user, :find_project, :authorize, except: [:preview]
before_filter :find_tracker, :find_templates, only: [:set_pulldown, :list_templates]
accept_api_auth :index, :list_templates, :load

Expand All @@ -21,7 +20,7 @@ def index

@template_map = {}
tracker_ids.each do |tracker_id|
templates = project_templates.search_by_tracker(tracker_id).order_by_position
templates = project_templates.search_by_tracker(tracker_id).sorted
@template_map[Tracker.find(tracker_id)] = templates if templates.any?
end

Expand All @@ -45,8 +44,13 @@ def show
end

def new
# create empty instance
@issue_template ||= IssueTemplate.new(author: @user, project: @project)
if params[:id].present?
@issue_template = IssueTemplate.find(params[:id]).dup
@issue_template.title = @issue_template.copy_title
else
# create empty instance
@issue_template ||= IssueTemplate.new(author: @user, project: @project)
end

if request.post?
@issue_template.safe_attributes = template_params
Expand All @@ -57,6 +61,12 @@ def new
render_form
end

def update
@issue_template.safe_attributes = template_params
@issue_template.checklist_json = checklists.to_json
save_and_flash(:notice_successful_update)
end

def edit
# Change from request.post to request.patch for Rails4.
return unless request.patch? || request.put?
Expand Down Expand Up @@ -143,11 +153,6 @@ def preview
render partial: 'common/preview'
end

# Reorder templates
def move
move_order(params[:to])
end

def orphaned_templates
orphaned = IssueTemplate.orphaned(@project.id)
render partial: 'orphaned_templates', locals: { orphaned_templates: orphaned }
Expand Down Expand Up @@ -182,15 +187,15 @@ def find_templates
@global_templates = global_templates(@tracker.id)
end

def move_order(method)
IssueTemplate.find(params[:id]).send "move_#{method}"
render_for_move_with_format
end

def save_and_flash(message)
return unless @issue_template.save
flash[:notice] = l(message)
redirect_to action: 'show', id: @issue_template.id, project_id: @project
respond_to do |format|
format.html do
flash[:notice] = l(message)
redirect_to action: 'show', id: @issue_template.id, project_id: @project
end
format.js { head 200 }
end
end

def render_form
Expand Down
9 changes: 7 additions & 2 deletions app/models/concerns/issue_template/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ module Common

validates :title, presence: true
validates :tracker, presence: true
acts_as_list scope: :tracker

acts_as_positioned scope: [:tracker_id]

scope :enabled, -> { where(enabled: true) }
scope :order_by_position, -> { order(:position) }
scope :sorted, -> { order(:position) }
scope :search_by_tracker, lambda { |tracker_id|
where(tracker_id: tracker_id) if tracker_id.present?
}
Expand Down Expand Up @@ -89,6 +90,10 @@ def confirm_disabled
errors.add :base, 'enabled_template_cannot_destroy'
false
end

def copy_title
"copy_of_#{title}"
end
end
end
end
2 changes: 1 addition & 1 deletion app/models/global_issue_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def get_templates_for_project_tracker(project_id, tracker_id = nil)
GlobalIssueTemplate.search_by_tracker(tracker_id)
.search_by_project(project_id)
.enabled
.order_by_position
.sorted
end
end
end
4 changes: 2 additions & 2 deletions app/models/issue_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ def get_inherit_templates(project_ids, tracker_id)
.search_by_tracker(tracker_id)
.enabled
.enabled_sharing
.order_by_position
.sorted
end

def get_templates_for_project_tracker(project_id, tracker_id = nil)
IssueTemplate.search_by_project(project_id)
.search_by_tracker(tracker_id)
.enabled
.order_by_position
.sorted
end
end
end
Loading

0 comments on commit 26f9aff

Please sign in to comment.