Skip to content

Commit

Permalink
Merge pull request #66 from akiko-pusu/develop
Browse files Browse the repository at this point in the history
Add code and CI setting for e2e test / Merg PR #62
  • Loading branch information
akiko-pusu committed Oct 27, 2016
2 parents 7f5c3c5 + e9002c2 commit c9f0375
Show file tree
Hide file tree
Showing 19 changed files with 455 additions and 10 deletions.
7 changes: 7 additions & 0 deletions Gemfile
Expand Up @@ -8,6 +8,13 @@ group :test do
#
gem 'shoulda', require: false
gem 'rubocop', require: false

gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'capybara'
gem 'launchy'
gem 'poltergeist', require: false
gem 'database_cleaner'
end

gem 'codeclimate-test-reporter', group: :test, require: nil
24 changes: 18 additions & 6 deletions README.rdoc
Expand Up @@ -149,8 +149,7 @@ NOTE: Please run "rake redmine:plugins:migrate" task because new column is added
Thanks for JohnArcher.
* Fixed invalid encoding. Thank you so much, Christoph. (#1178)
* Fixed append "null" string to issue title field. (IssueID: #1268)
* Prevent to load template when update and redirect with validation error.
(#1151, #1254)
* Prevent to load template when update and redirect with validation error. (#1151, #1254)

=== 0.0.5

Expand Down Expand Up @@ -183,13 +182,26 @@ NOTE: Please run "rake redmine:plugins:migrate" task because new column is added

Please see wercker.yml for more details.

% cd REDMINE_ROOT_DIR
% export RAILS_ENV=test
% bundle exec rake redmine:plugins:test PLUGIN=redmine_issue_templates
% cd REDMINE_ROOT_DIR
% export RAILS_ENV=test
% bundle exec rake redmine:plugins:test PLUGIN=redmine_issue_templates

or

% bundle exec rake redmine_issue_templates:test
% bundle exec rake redmine_issue_templates:test

==== Run spec

Please see wercker.yml for more details.

% cd REDMINE_ROOT_DIR
% export RAILS_ENV=test
% bundle exec rake redmine_issue_templates:spec

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

% bundle exec rake redmine_issue_templates:spec DRIVER='selenium'


=== Report
Expand Down
2 changes: 2 additions & 0 deletions app/views/issue_templates/_list_templates.html.erb
@@ -1,10 +1,12 @@
<table class="list template_list">
<thead>
<tr>
<th><%=h l(:issue_title) %></th>
<th><%=h l(:issue_description) %></th>
<th><%= l(:field_is_default) %></th>
<th><%=h l(:button_apply, default: 'Apply') %></th>
</tr>
</thead>
<% issue_templates.each do |template| %>
<tr class="<%= cycle('odd', 'even') %> template_data">
<td>
Expand Down
7 changes: 5 additions & 2 deletions assets/javascripts/issue_templates.js
Expand Up @@ -81,8 +81,11 @@ function load_template(target_url, confirm_msg, should_replaced) {
obj.description = (obj.description === null) ? '' : obj.description;
obj.issue_title = (obj.issue_title === null) ? '' : obj.issue_title;

issue_description.val(oldVal + obj.description);
issue_subject.val(oldSubj + obj.issue_title);
if(oldVal.replace(/(?:\r\n|\r|\n)/g, '').trim() != obj.description.replace(/(?:\r\n|\r|\n)/g, '').trim())
issue_description.val(oldVal + obj.description);
if(oldSubj.trim() != obj.issue_title.trim())
issue_subject.val(oldSubj + obj.issue_title);

try {
if (CKEDITOR.instances.issue_description)
CKEDITOR.instances.issue_description.setData(oldVal + template[issue_template].description);
Expand Down
23 changes: 23 additions & 0 deletions lib/tasks/test.rake
Expand Up @@ -8,4 +8,27 @@ namespace :redmine_issue_templates do
t.pattern = 'plugins/redmine_issue_templates/test/**/*_test.rb'
t.verbose = true
end

desc 'Run spec for redmine_issue_template plugin'
begin
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = 'plugins/redmine_issue_templates/spec/**/*_spec.rb'
t.rspec_opts = ['-I plugins/redmine_issue_templates/spec', '--format documentation']
end
task default: :spec
rescue LoadError
puts 'yardoc failed.'
end

desc 'Run rubycritic for redmine_issue_template plugin'
begin
require 'rubycritic/rake_task'
RubyCritic::RakeTask.new do |t|
t.paths = FileList['plugins/redmine_issue_templates/app']
t.options = '-p redmine_issue_templates_critic --no-browser --mode-ci'
end
rescue LoadError
puts 'rubycritic failed.'
end
end
4 changes: 3 additions & 1 deletion lib/tasks/yard.rake
Expand Up @@ -6,7 +6,9 @@ begin
YARD::Rake::YardocTask.new(:yardoc) do |t|
files = ['plugins/redmine_issue_templates/lib/**/*.rb', 'plugins/redmine_issue_templates/app/**/*.rb'] # exclude test file
t.files = files
t.options += ['--output-dir', './redmine_issue_templates_doc']
t.options += ['--output-dir', './redmine_issue_templates_doc',
'--readme', 'plugins/redmine_issue_templates/README.rdoc',
' - plugins/redmine_issue_templates/README.rdoc']
end
end
rescue LoadError
Expand Down
2 changes: 1 addition & 1 deletion redmine-ready.sh
Expand Up @@ -18,7 +18,7 @@ ls -a | grep -v -E 'redmine-ready\.sh|wercker\.yml' | xargs rm -rf

shopt -s dotglob
mv ../redmine-${REDMINE_VERSION}/* ./
gem install simplecov simplecov-rcov yard
gem install simplecov simplecov-rcov yard rspec
gem update bundler


Expand Down
6 changes: 6 additions & 0 deletions spec/factories/enabled_modules.rb
@@ -0,0 +1,6 @@
FactoryGirl.define do
factory :enabled_module do
project_id 1
name 'issue_templates'
end
end
7 changes: 7 additions & 0 deletions spec/factories/issue_statuses.rb
@@ -0,0 +1,7 @@
FactoryGirl.define do
factory :issue_status do
sequence(:name) { |n| "status-name: #{n}" }
sequence(:position) { |n| n }
is_closed false
end
end
9 changes: 9 additions & 0 deletions spec/factories/issue_template_settings.rb
@@ -0,0 +1,9 @@
FactoryGirl.define do
factory :issue_template_setting do |t|
association :project
t.sequence(:help_message) { |n| "Project-#{n}: temlpate help" }
t.enabled true
t.inherit_templates false
t.should_replaced false
end
end
12 changes: 12 additions & 0 deletions spec/factories/issue_templates.rb
@@ -0,0 +1,12 @@
FactoryGirl.define do
factory :issue_template do |t|
association :project
association :tracker
t.sequence(:title) { |n| "template-title: #{n}" }
t.sequence(:description) { |n| "template-description: #{n}" }
t.sequence(:note) { |n| "template-note: #{n}" }
t.sequence(:position) { |n| n }
t.enabled true
t.author_id 1
end
end
9 changes: 9 additions & 0 deletions spec/factories/projects.rb
@@ -0,0 +1,9 @@
FactoryGirl.define do
factory :project do
sequence(:name) { |n| "project-name: #{n}" }
sequence(:description) { |n| "project-description: #{n}" }
sequence(:identifier) { |n| "project-#{n}" }
homepage 'http://ecookbook.somenet.foo/'
is_public true
end
end
13 changes: 13 additions & 0 deletions spec/factories/trackers.rb
@@ -0,0 +1,13 @@
FactoryGirl.define do
factory :tracker do
sequence(:name) { |n| "tracker-name: #{n}" }
sequence(:position) { |n| n }
default_status_id 1
trait :with_default_status do
after(:build) do |tracker|
status = FactoryGirl.create(:issue_status)
tracker.default_status_id = status.id
end
end
end
end

0 comments on commit c9f0375

Please sign in to comment.