100 Commits

Author SHA1 Message Date
Alexander Meindl
83b53220d0 Use github /checkout@v3 2022-10-24 15:35:21 +02:00
Alexander Meindl
62503fe309 Fix i18n bug. Redmine 4.2 is required. Version bump 2022-10-23 07:45:14 +02:00
Alexander Meindl
16c789ef2c Fix rubocop offenses 2022-10-22 13:24:47 +02:00
Alexander Meindl
c1d3257ca2 switch to actions/checkout@v2 2022-09-24 18:07:25 +02:00
Alexander Meindl
aea93ffbff refactor render, see https://rails-bestpractices.com/posts/2010/12/04/simplify-render-in-views/ 2022-09-18 14:43:30 +02:00
Alexander Meindl
b6c0844738 version bump and changelog update 2022-08-07 04:52:00 +02:00
Alexander Meindl
9e197586ea Merge pull request #100 from hybridvision/url-formatting-fix
Fix URL formatting in messages
2022-08-07 04:44:48 +02:00
hybridvision
acce7477f8 Fix URL formatting in messages
Certain URLs in the Messenger are formatted as Markdown, which [doesn't work with Slack](https://stackoverflow.com/a/36304585). URLs elsewhere are formatted correctly, so this change addresses the inconsistency and fixes the links for Slack.

Fixes #75
2022-07-20 19:30:40 +02:00
Alexander Meindl
b6a0674b1f rubocop offenses fixed 2022-06-28 08:13:51 +02:00
Alexander Meindl
6b894a47f6 Rename Kennwort to Passwort 2022-04-19 12:52:34 +02:00
Alexander Meindl
5f15566f3a rubocop-minitest added - gem 2022-04-11 16:38:01 +02:00
Alexander Meindl
105813c866 rubocop-minitest added 2022-04-11 16:14:31 +02:00
Alexander Meindl
4373a7c410 Use bulk for migration 2022-01-13 18:11:18 +01:00
Alexander Meindl
8040469925 New password string again 2021-12-09 19:55:11 +01:00
Alexander Meindl
829eda357f Use new passwords string 2021-12-09 17:48:15 +01:00
Alexander Meindl
077bdc6018 Fix settings, which should support fallback with redmine_plugin_kit 2021-12-08 16:47:56 +01:00
Alexander Meindl
6bbc235732 Version bump and changelog update 2021-12-08 15:58:08 +01:00
Alexander Meindl
a4dabae9c9 Use redmine_plugin kit as loader 2021-12-07 19:40:32 +01:00
Alexander Meindl
923d3b8408 Working on zeitwerk support 2021-11-23 19:42:25 +01:00
Alexander Meindl
bba0807350 remove ruby 2.5 tests and add ruby 3.0 tests 2021-11-11 10:21:31 +01:00
Alexander Meindl
3f12e31568 Ruby 2.6 required 2021-11-11 09:33:20 +01:00
Alexander Meindl
d046b7bec9 Switch to postgres14 for github actions 2021-10-05 07:06:15 +02:00
Alexander Meindl
959b9ce041 correct note 2021-09-20 12:46:51 +02:00
Alexander Meindl
1c34d31623 adjust rubocop for new rubocop version 2021-09-14 19:58:36 +02:00
Alexander Meindl
d04fcc814a Version bump to 1.0.10 2021-08-24 18:06:30 +02:00
Alexander Meindl
1730fb05fd Move asynchron delivery job to default Rails directory 2021-08-24 18:01:48 +02:00
Alexander Meindl
7326c81c5f Merge pull request #91 from Contargo/asynchronous-job
Use asynchronous ActiveJob for message delivery
2021-08-24 17:47:56 +02:00
Florian Krupicka
05d4b5bc8d Fix: missed a small param copied from the original network call 2021-08-24 17:13:55 +02:00
Florian Krupicka
f4fbf45895 Use asynchronous ActiveJob for message delivery
Calling out to a 3rd party web service like Slack or Mattermost blocks
the request for the current Redmine user. Depending on network latency,
this can result in very slow response on any action that is notified via
`redmine_messenger`.

Instead the backend call should make use of Rails builtin asynchronous
background job queuing (the same as used for Redmine mails), returning
to the user earlier.

We don't specify the actual queue backend for this job, so any Redmine
installation can select an appropiate queue backend by themselves or
simply use the default builtin backends.
2021-08-24 16:58:40 +02:00
Alexander Meindl
4fa7ed5d71 Remove unused css class 2021-07-15 15:54:04 +02:00
Alexander Meindl
6af8205469 delete project settings, if project is removed 2021-07-09 17:22:28 +02:00
Alexander Meindl
7d39ba99ec use project relation for messenger_setting 2021-07-09 17:09:20 +02:00
Alexander Meindl
28f5d2d0c6 adjust number of available languages 2021-07-07 07:01:18 +02:00
Alexander Meindl
32b0b01ae0 Merge pull request #89 from evroon/patch-2
Create Dutch locale
2021-07-07 06:49:13 +02:00
Alexander Meindl
b90cfe5334 Merge pull request #88 from evroon/patch-1
Fix typos in English locale
2021-07-07 06:47:21 +02:00
Erik Vroon
53e00d1abb Replace 'en' by 'nl' in nl.yml 2021-07-06 20:50:27 +02:00
Erik Vroon
78d9896647 Small improvements in nl locale 2021-07-06 20:48:36 +02:00
Erik Vroon
1bb62a1cbc Create Dutch locale 2021-07-06 20:40:57 +02:00
Erik Vroon
f6bc1310ca Fix typos in English locale 2021-07-06 20:40:37 +02:00
Alexander Meindl
eb9de1bc8e rename env JENKINS to COVERAGE 2021-05-17 16:48:10 +02:00
Alexander Meindl
51de72e3fb Fix version check 2021-04-18 16:05:57 +02:00
Alexander Meindl
e47c55130d Fix documentation 2021-04-18 16:04:04 +02:00
Alexander Meindl
dadaa32a57 frozen_string_literal, Coding standards fixed and ruby 2.7 warnings - redmine 4.1 and ruby 2.5 is required 2021-04-18 15:58:57 +02:00
Alexander Meindl
67a8faa284 fix problem with frozen string #85 2021-04-06 10:26:55 +02:00
Alexander Meindl
36d8261d4a Remove not required source from Gemfile 2021-04-06 07:47:00 +02:00
Alexander Meindl
385b6f6cef Update gem setup for tests 2021-04-06 07:46:13 +02:00
Alexander Meindl
fae0efbc7c Do not test master with ruby 2.4, because it is no longer supported by redmine 2021-04-02 07:55:39 +02:00
Alexander Meindl
b290a59f5c Add Redmine 4.2 to github actions 2021-03-28 09:39:04 +02:00
Alexander Meindl
18e3cb6af5 add db to matrix again 2021-03-24 16:38:23 +01:00
Alexander Meindl
2678b5512b github action does not execpt multiple excludes, use include 2021-03-24 16:35:24 +01:00
Alexander Meindl
887d3917bd github action does not execpt multiple excludes, use include 2021-03-24 16:34:13 +01:00
Alexander Meindl
d226072f34 Add ruby 2.7 to github actions test 2021-03-24 16:27:54 +01:00
Alexander Meindl
6e6378b7e7 Try to fix mysql - try user name2 2021-03-18 08:32:33 +01:00
Alexander Meindl
6713c3749b Try to fix mysql - try user name2 2021-03-18 08:28:39 +01:00
Alexander Meindl
514a6f3cae Try to fix mysql - try user name 2021-03-18 08:24:20 +01:00
Alexander Meindl
677d99a2cc Try to fix mysql with random port 2021-03-18 08:07:35 +01:00
Alexander Meindl
add5f43ebd try different port to fix github actions2 2021-03-18 07:36:58 +01:00
Alexander Meindl
b63773c5ab try different port to fix github actions 2021-03-18 07:35:40 +01:00
Alexander Meindl
8715f90b8f Fix badges and add mysql db name 2021-03-18 07:32:45 +01:00
Alexander Meindl
d5658cbb95 Split actions to run mysql and postgres services only for required db 2021-03-18 07:17:53 +01:00
Alexander Meindl
835e0fc5f9 Try mysql 8 to fix github actions 2021-03-18 07:01:29 +01:00
Alexander Meindl
693bedf63c Try to fix mysql service for github actions 2021-03-18 06:55:12 +01:00
Alexander Meindl
6c9351933d remove Gemfile.lock and adjust .gitignore 2021-03-13 16:01:43 +01:00
Alexander Meindl
062f77e4b4 Fix syntax error for pt-BR and ajust unit test 2021-03-13 15:59:33 +01:00
Alexander Meindl
5db63a67e2 Merge pull request #86 from lucianocosta/master
Create pt-BR.yml
2021-03-13 15:46:21 +01:00
Luciano Costa
82d5dd2cd0 Merge pull request #1 from lucianocosta/lucianocosta-patch-pt-br
Create pt-BR.yml
2021-03-13 10:23:27 -03:00
Luciano Costa
b21ac109f3 Create pt-BR.yml 2021-03-13 10:22:48 -03:00
Alexander Meindl
f6b25521a7 switch from actions/setup-ruby@v1 to ruby/setup-ruby@v1 2021-03-03 07:35:24 +01:00
Alexander Meindl
3c7b14b3f2 Rubocop conding standard fixed 2021-01-29 12:04:06 +01:00
Alexander Meindl
568a477431 remove architecture 2020-12-01 15:02:38 +01:00
Alexander Meindl
66813ff691 Merge branch 'master' of git.alphanodes.com:redmine_messenger 2020-12-01 12:03:59 +01:00
Alexander Meindl
60b78f973b Run tests for Redmine 4.0 2020-12-01 12:03:54 +01:00
Claudia Meindl
6c84096c52 update image for settings 2020-12-01 11:56:30 +01:00
Claudia Meindl
d78435895a update readme and images 2020-12-01 11:54:03 +01:00
Alexander Meindl
efc562b855 Fix testing badge, again 2020-12-01 07:56:35 +01:00
Alexander Meindl
357148e580 Fix testing badge 2020-12-01 07:52:53 +01:00
Alexander Meindl
9823c578a5 Switching from travis to github actions for testing 2020-12-01 07:49:38 +01:00
Alexander Meindl
d3cdce03d0 Merge pull request #83 from iquiw/label_copied_from
copied_from translation and issue ID fix
2020-12-01 07:10:02 +01:00
Iku Iwasa
f7d25d8a28 Resolve copied_from issue ID to show issue URL 2020-12-01 08:31:07 +09:00
Iku Iwasa
5e7b1813c0 Correct to use label_copied_from translation key 2020-11-30 23:47:31 +09:00
Alexander Meindl
4b74808a6f Update ruby version for travis test 2020-11-24 15:38:39 +01:00
Alexander Meindl
16f106712e Merge pull request #81 from iquiw/comment-field
Move update comment to attachment field
2020-11-24 15:31:30 +01:00
Alexander Meindl
f7d62852d5 Merge pull request #82 from iquiw/group-assignee
Support Group assignee as well as User
2020-11-24 15:30:07 +01:00
Iku Iwasa
e7f6de9af2 Support Group assignee as well as User 2020-11-23 11:15:50 +09:00
Iku Iwasa
e5d5a94119 Move update comment to attachment field
so that it is not hidden when issue description is long.
2020-11-23 10:41:17 +09:00
Alexander Meindl
24095bf9db drop validate_url gem 2020-11-14 18:43:09 +01:00
Alexander Meindl
8943040f4d Fix for rubocop update 2020-11-05 14:40:42 +01:00
Alexander Meindl
c2c8023f14 Merge pull request #79 from iquiw/fix-find-error
Fix find error when deleting attachment, removing parent issue ID
2020-10-25 10:20:31 +01:00
Iku Iwasa
45531d783a Fix RecordNotFound error when removing parent issue ID
Using find_by instead of find.
2020-10-25 18:07:14 +09:00
Iku Iwasa
e7e6539500 Fix RecordNotFound error when deleting attachments
Using find_by instead of find.
2020-10-25 18:07:14 +09:00
Alexander Meindl
5623961366 use is_a? 2020-10-09 09:51:18 +02:00
Alexander Meindl
3f61d8cde7 rubocop fix 2020-10-09 09:09:27 +02:00
Alexander Meindl
f843f7ea48 Do not notify locked watchers, see https://www.redmine.org/issues/33935 2020-09-01 17:31:03 +02:00
Alexander Meindl
cb23763b63 Fix coding standards 2020-08-30 17:27:05 +02:00
Alexander Meindl
61f54fce26 Merge pull request #74 from iquiw/journal-anchor
Add journal anchor to issue update notification URL
2020-08-30 17:12:13 +02:00
Alexander Meindl
6477a02afe Merge pull request #73 from Ujifman/master
Added watcher_users to list of users to be notitfied
2020-08-30 17:00:30 +02:00
Iku Iwasa
c9d6028792 Add journal anchor to issue update notification URL 2020-08-30 22:39:26 +09:00
Igor Pronin
1c45192653 Added watcher_users to list of users to be notitfied 2020-08-25 12:16:45 +03:00
Alexander Meindl
2a59483fca Show author name, if author changes of a issue - refactored 2020-08-25 09:35:39 +02:00
Alexander Meindl
1b6c00b4c0 Show author name, if author changes of a issue 2020-08-25 09:32:51 +02:00
58 changed files with 1025 additions and 581 deletions

37
.github/workflows/linters.yml vendored Normal file
View File

@@ -0,0 +1,37 @@
name: Run Linters
on:
push:
pull_request:
schedule:
- cron: '30 5 * * *'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Gemfile
run: |
touch .enable_dev
sed -i "3isource 'https://rubygems.org'" Gemfile
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
bundler-cache: true
- name: Setup gems
run: |
bundle install --jobs 4 --retry 3
- name: Run RuboCop
run: |
bundle exec rubocop -S
- name: Run Slim-Lint
run: |
bundle exec slim-lint app/views
if: always()

View File

@@ -1,34 +0,0 @@
name: Run RuboCop
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x
- name: Set Gemfile
run: |
echo "">> Gemfile
echo "group :test do">> Gemfile
echo " gem 'rubocop', require: false" >> Gemfile
echo " gem 'rubocop-performance', require: false" >> Gemfile
echo " gem 'rubocop-rails', require: false" >> Gemfile
echo "end">> Gemfile
- name: Setup gems
run: |
gem install bundler
bundle install --jobs 4 --retry 3
- name: Run RuboCop
run: |
bundle exec rubocop -S

View File

@@ -1,4 +1,4 @@
name: Run Tests
name: Tests
on:
push:
pull_request:
@@ -7,25 +7,117 @@ on:
jobs:
test:
name: ${{ matrix.redmine }} ruby-${{ matrix.ruby }}
runs-on: ubuntu-latest
strategy:
matrix:
redmine:
- v4.0
- v4.1
- trunk
ruby:
- v2.4
- v2.6
database:
- sqlite3
- postgres
ruby: ['2.7', '3.0', '3.1']
redmine: ['4.2-stable', '5.0-stable', 'master']
db: ['postgres', 'mysql']
exclude:
- ruby: '3.0'
redmine: 4.2-stable
- ruby: '3.1'
redmine: 4.2-stable
fail-fast: false
services:
postgres:
image: postgres:14
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: 'BestPasswordEver'
ports:
# will assign a random free host port
- 3306/tcp
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- name: Redmine plugin test
uses: two-pack/redmine-plugin-test-action@v2
- name: Verify MySQL connection from host
run: |
mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports[3306] }} -uroot -pBestPasswordEver -e "SHOW DATABASES"
if: matrix.db == 'mysql'
- name: Checkout Redmine
uses: actions/checkout@v3
with:
plugin_name: redmine_messenger
redmine_version: ${{ matrix.redmine }}
ruby_version: ${{ matrix.ruby }}
repository: redmine/redmine
ref: ${{ matrix.redmine }}
path: redmine
- name: Checkout redmine_messenger
uses: actions/checkout@v3
with:
repository: AlphaNodes/redmine_messenger
path: redmine/plugins/redmine_messenger
- name: Update package archives
run: sudo apt-get update --yes --quiet
- name: Install package dependencies
run: >
sudo apt-get install --yes --quiet
build-essential
cmake
libicu-dev
libmysqlclient-dev
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Prepare Redmine source
working-directory: redmine
run: |
cp plugins/redmine_messenger/test/support/database-mysql.yml config/database.yml
cp plugins/redmine_messenger/test/support/configuration.yml config/configuration.yml
- name: Install Ruby dependencies
working-directory: redmine
run: |
bundle config set --local without 'development'
bundle install --jobs=4 --retry=3
- name: Run Redmine rake tasks
env:
RAILS_ENV: test
MYSQL_PORT: ${{ job.services.mysql.ports[3306] }}
working-directory: redmine
run: |
bundle exec rake generate_secret_token
bundle exec rake db:create db:migrate redmine:plugins:migrate
bundle exec rake db:test:prepare
- name: Run tests
env:
RAILS_ENV: test
MYSQL_PORT: ${{ job.services.mysql.ports[3306] }}
working-directory: redmine
run: bundle exec rake redmine:plugins:test NAME=redmine_messenger RUBYOPT="-W0"
- name: Run uninstall test
env:
RAILS_ENV: test
MYSQL_PORT: ${{ job.services.mysql.ports[3306] }}
working-directory: redmine
run: bundle exec rake redmine:plugins:migrate NAME=redmine_messenger VERSION=0

2
.gitignore vendored
View File

@@ -1,8 +1,10 @@
.DS_Store
coverage/
Gemfile.lock
.buildpath
.project
.settings/
docs/_build
docs/_static
docs/_templates
.enable_dev

View File

@@ -1,24 +1,39 @@
require:
- rubocop-performance
- rubocop-rails
- rubocop-minitest
AllCops:
TargetRubyVersion: 2.7
TargetRailsVersion: 5.2
NewCops: enable
Rails:
Enabled: true
AllCops:
TargetRubyVersion: 2.4
TargetRailsVersion: 5.2
NewCops: enable
Minitest/MultipleAssertions:
Max: 5
Enabled: true
Minitest/AssertPredicate:
Enabled: false
Metrics:
Enabled: false
Metrics/ParameterLists:
Enabled: true
CountKeywordArgs: false
Layout/LineLength:
Max: 140
Rails/ApplicationJob:
Enabled: false
Lint/AmbiguousOperatorPrecedence:
Enabled: false
Rails/ApplicationRecord:
Enabled: false
@@ -37,17 +52,55 @@ Performance/ChainArrayAllocation:
Style/AutoResourceCleanup:
Enabled: true
Style/ExpandPathArguments:
Enabled: true
Exclude:
- test/**/*
Style/FrozenStringLiteralComment:
Enabled: false
Enabled: true
Exclude:
- '/**/*.rsb'
Style/OptionHash:
Enabled: true
SuspiciousParamNames:
- options
- api_options
- opts
- args
- params
- parameters
- settings
Exclude:
- lib/redmine_messenger/patches/*.rb
# postgresql and mysql are supported
# autodetect does not work without database configuration
Rails/BulkChangeTable:
Enabled: true
Database: postgresql
Style/ReturnNil:
Enabled: true
Style/UnlessLogicalOperators:
Enabled: true
Style/MethodCallWithArgsParentheses:
Enabled: true
AllowParenthesesInMultilineCall: true
AllowParenthesesInChaining: true
EnforcedStyle: omit_parentheses
Style/Documentation:
Enabled: false
Style/ExpandPathArguments:
Enabled: false
Style/HashTransformKeys:
Enabled: false
Style/HashTransformValues:
Enabled: false
Naming/VariableNumber:
Enabled: false

View File

@@ -1,3 +1,40 @@
linters:
LineLength:
max: 140
RuboCop:
ignored_cops:
- Layout/ArgumentAlignment
- Layout/ArrayAlignment
- Layout/BlockEndNewline
- Layout/EmptyLineAfterGuardClause
- Layout/HashAlignment
- Layout/IndentationConsistency
- Layout/IndentationWidth
- Layout/IndentFirstArgument
- Layout/IndentFirstArrayElement
- Layout/IndentFirstHashElement
- Layout/MultilineArrayBraceLayout
- Layout/MultilineAssignmentLayout
- Layout/MultilineBlockLayout
- Layout/MultilineHashBraceLayout
- Layout/MultilineMethodCallBraceLayout
- Layout/MultilineMethodCallIndentation
- Layout/MultilineMethodDefinitionBraceLayout
- Layout/MultilineOperationIndentation
- Layout/TrailingBlankLines
- Layout/TrailingEmptyLines
- Layout/TrailingWhitespace
- Lint/BlockAlignment
- Lint/EndAlignment
- Lint/Void
- Metrics/BlockLength
- Metrics/BlockNesting
- Layout/LineLength
- Naming/FileName
- Rails/OutputSafety
- Style/ConditionalAssignment
- Style/FrozenStringLiteralComment
- Style/IdenticalConditionalBranches
- Style/IfUnlessModifier
- Style/Next
- Style/WhileUntilModifier

View File

@@ -1,47 +0,0 @@
language: ruby
os: linux
dist: xenial
rvm:
- 2.6.6
- 2.5.8
- 2.4.9
services:
- mysql
- postgresql
env:
- REDMINE_VER=4.0-stable DB=postgresql
- REDMINE_VER=master DB=postgresql
- REDMINE_VER=4.0-stable DB=mysql
- REDMINE_VER=master DB=mysql
notifications:
webhooks:
urls:
secure: "lwJzu9BU7AVhHnROzEA6agagwsqVAaTzgtvwTlw4CwSUv0ypNXNi9kjJUvOgSit3BnkSccC9xYlYNOYw5OOmsmjyUDU4/LUVqd0DRQjW3FXU9EFFPGQq9srJikHOHobfnutxGwMYFE4ftLI08PzsL7bYEg39Ps3pwwWsiIKnKKI0DPmdQH5PzC63jF/EByrLZsfqGHOirgXDnxmwgmrQ14vOpp3lHjgNgx9wNALpSgAztKeK1Wd8KayLYXweu+LQx9IwJfLqvk6hhWW15vjkIhvK7ooYSGXx+Hlwg3jyFSyX5jButUT4vwlWdJeAoNO/sWpdKXv4AifGXYsbcF/LMHCaaVgwBm/pe/YlK2LrqFlpm7MFuqyO1w4AnIA7rC8wZp/dUU5bJITZgN3sTAbLyTIbF8cbMfbDy3IWP8Oub7K/0ATUD7vNBVuyxfdGG61xOv/RDQhzrGwUArJ/xJfdU77MZkQUnaGb0vcwmRLIxyPdZWPz9ntzCbBxFblPWApCw+CWOeM3OuR6tdVqSVuZx3aG87TTzW+S9lLe8PJ5HYgA6+rPkc04zolJMftnFVlUl3LQIKvV2QkPSnr9bcePR5YSoJJKLBVofUsg/btVkQ1OxhWn53Td/nQp7u8qosmyQjCjMiP6Po1e9Enr89FY8Yxkw2dQba5sumQRbB39bj0="
on_success: change
on_failure: always
before_install:
- export PLUGIN_NAME=redmine_messenger
- export REDMINE_GIT_REPO=git://github.com/redmine/redmine.git
- export REDMINE_PATH=$HOME/redmine
- export BUNDLE_GEMFILE=$REDMINE_PATH/Gemfile
- export RAILS_ENV=test
- git clone $REDMINE_GIT_REPO $REDMINE_PATH
- cd $REDMINE_PATH
- if [[ "$REDMINE_VER" != "master" ]]; then git checkout -b $REDMINE_VER origin/$REDMINE_VER; fi
- if [[ "$REDMINE_VER" != "master" ]]; then cp $TRAVIS_BUILD_DIR/test/support/Gemfile.local $REDMINE_PATH; fi
- ln -s $TRAVIS_BUILD_DIR $REDMINE_PATH/plugins/$PLUGIN_NAME
- cp $TRAVIS_BUILD_DIR/test/support/additional_environment.rb $REDMINE_PATH/config/
- cp $TRAVIS_BUILD_DIR/test/support/database-$DB-travis.yml $REDMINE_PATH/config/database.yml
before_script:
- bundle exec rake db:create db:migrate redmine:plugins:migrate
script:
- if [[ "$REDMINE_VER" != "master" ]] && [[ "$DB" == "postgresql" ]]; then rubocop plugins/$PLUGIN_NAME; fi
- bundle exec rake redmine:plugins:test NAME=$PLUGIN_NAME RUBYOPT="-W0"
- bundle exec rake redmine:plugins:migrate NAME=$PLUGIN_NAME VERSION=0

View File

@@ -1,8 +1,52 @@
Changelog
=========
1.0.14
------
- Fix i18n bug: switch back to used language after sending message
- Ruby 2.7 or higher is required. Maintained ruby versions are supported only, see <https://www.ruby-lang.org/en/downloads/>
- Redmine 4.2 is required. Use git tag 1.0.15, if you use an older version.
1.0.13
------
- Slack compatible url formating, see #100
1.0.12
------
- Fixed settings bug introducted with version 1.0.11
1.0.11
------
- Upcoming Redmine 5 support
- Ruby 3 support
- Ruby 2.6 or higher is required
- Use redmine_plugin_kit as plugin loader
1.0.10
------
- Web service is called asynchron which does not block performance while sending message
1.0.9
-----
- Redmine 4.1 is required. Use git tag 1.0.8, if you use an older version.
- Redmine 4.2 support
- Ruby 2.5 or higher is required
1.0.8
-----
- Drop testing with travis - we use github actions
- Add translation pt-BR - thanks to @lucianocosta
1.0.7
-----
- Added feature to send messages directly to users to be notified - thanks to @Ujifman
1.0.6
@@ -23,7 +67,6 @@ Changelog
- ruby 2.4.x or newer is required
1.0.4
-----
@@ -34,7 +77,6 @@ Changelog
- Redmine 4 support
1.0.2
-----

19
Gemfile
View File

@@ -1,4 +1,19 @@
source 'https://rubygems.org'
# frozen_string_literal: true
gem 'redmine_plugin_kit'
gem 'slim-rails'
gem 'validate_url'
group :development do
# this is only used for development.
# if you want to use it, do:
# - create .enable_dev file in messenger directory
# - remove rubocop entries from REDMINE/Gemfile
# - remove REDMINE/.rubocop* files
if File.file? File.expand_path './.enable_dev', __dir__
gem 'rubocop', require: false
gem 'rubocop-minitest', require: false
gem 'rubocop-performance', require: false
gem 'rubocop-rails', require: false
gem 'slim_lint', require: false
end
end

View File

@@ -3,7 +3,7 @@ Messenger plugin for Redmine
This plugin posts updates to issues in your Redmine installation to [Slack](https://slack.com/), [Rocket.Chat](https://rocket.chat/), [Discord](https://discordapp.com/) or [Mattermost](https://about.mattermost.com/) channel.
[![Rate at redmine.org](https://img.shields.io/badge/rate%20at-redmine.org-blue.svg?style=fla)](https://www.redmine.org/plugins/redmine_messenger) [![Build Status](https://travis-ci.org/AlphaNodes/redmine_messenger.svg?branch=master)](https://travis-ci.org/AlphaNodes/redmine_messenger) ![Run RuboCop](https://github.com/AlphaNodes/redmine_messenger/workflows/Run%20RuboCop/badge.svg) ![Run Tests](https://github.com/AlphaNodes/redmine_messenger/workflows/Run%20Tests/badge.svg)
[![Rate at redmine.org](https://img.shields.io/badge/rate%20at-redmine.org-blue.svg?style=fla)](https://www.redmine.org/plugins/redmine_messenger) [![Run Linters](https://github.com/AlphaNodes/redmine_messenger/workflows/Run%20Linters/badge.svg)](https://github.com/AlphaNodes/redmine_messenger/actions?query=workflow%3A%22Run+Linters%22) [![Tests](https://github.com/AlphaNodes/redmine_messenger/actions/workflows/tests.yml/badge.svg)](https://github.com/AlphaNodes/redmine_messenger/actions/workflows/tests.yml)
Features
--------
@@ -25,9 +25,9 @@ Features
Screenshot
----------
Mattermost output:
Rocket.Chat output:
![screenshot](https://raw.githubusercontent.com/alphanodes/redmine_messenger/master/assets/images/screenshot_mattermost.png)
![screenshot](https://raw.githubusercontent.com/alphanodes/redmine_messenger/master/assets/images/screenshot_rocketchat.png)
Redmine configuration:
@@ -69,14 +69,17 @@ You have to add /slack after your webhook url.
Go to Rocket.Chat documentation [Incoming WebHook Scripting](https://rocket.chat/docs/administrator-guides/integrations/) for more information to set up Incoming WebHook
Requirements
------------
* Redmine version >= 4.0.0
* Ruby version >= 2.4.0
* Redmine version >= 4.2.0
* Ruby version >= 2.7.0
If you want to use it with Redmine 3.x, use git tag 1.0.5
### Older versions
* If you want to use it with Redmine 3.x, use git tag 1.0.5
* If you want to use it with Redmine 4.0, use git tag 1.0.7
* If you want to use it with Redmine 4.1, use git tag 1.0.13
Installation
------------
@@ -96,7 +99,6 @@ Channel to the channel's handle (be careful, this is not the channel's display n
visible to users, you can find each channel's handle by navigating inside the channel
and clicking the down-arrow and selecting view info).
Uninstall
---------
@@ -108,14 +110,13 @@ Uninstall ``redmine_messenger``
Restart Redmine (application server)
Credits
-------
The source code is forked from
- [redmine_rocketchat](https://github.com/phlegx/redmine_rocketchat)
- [redmine_mattermost](https://github.com/altsol/redmine_mattermost)
- [redmine-slack](https://github.com/sciyoshi/redmine-slack)
* [redmine_rocketchat](https://github.com/phlegx/redmine_rocketchat)
* [redmine_mattermost](https://github.com/altsol/redmine_mattermost)
* [redmine-slack](https://github.com/sciyoshi/redmine-slack)
Special thanks to the original author and contributors for making this awesome hook for Redmine. This fork is just refactored to use Messenger-namespaced configuration options in order to use all hooks for Rocket.Chat, Mattermost AND Slack in a Redmine installation.

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class MessengerSettingsController < ApplicationController
before_action :find_project_by_project_id
before_action :authorize
@@ -8,10 +10,10 @@ class MessengerSettingsController < ApplicationController
flash[:notice] = l :notice_successful_update
redirect_to settings_project_path(@project, tab: 'messenger')
else
flash[:error] = setting.errors.full_messages.flatten.join("\n")
flash[:error] = setting.errors.full_messages.flatten.join "\n"
respond_to do |format|
format.html { redirect_back_or_default(settings_project_path(@project, tab: 'messenger')) }
format.api { render_validation_errors(setting) }
format.html { redirect_to settings_project_path(@project, tab: 'messenger') }
format.api { render_validation_errors setting }
end
end
end

View File

@@ -1,8 +1,10 @@
# frozen_string_literal: true
module MessengerProjectsHelper
def project_settings_tabs
tabs = super
if User.current.allowed_to?(:manage_messenger, @project)
if User.current.allowed_to? :manage_messenger, @project
tabs << { name: 'messenger',
action: :show,
partial: 'messenger_settings/show',

View File

@@ -0,0 +1,25 @@
# frozen_string_literal: true
require 'net/http'
require 'uri'
class MessengerDeliverJob < ActiveJob::Base
queue_as :default
def perform(url, params)
uri = URI url
http_options = { use_ssl: uri.scheme == 'https' }
http_options[:verify_mode] = OpenSSL::SSL::VERIFY_NONE unless RedmineMessenger.setting? :messenger_verify_ssl
begin
req = Net::HTTP::Post.new uri
req.set_form_data payload: params.to_json
Net::HTTP.start uri.hostname, uri.port, http_options do |http|
response = http.request req
Rails.logger.warn response.inspect unless [Net::HTTPSuccess, Net::HTTPRedirection, Net::HTTPOK].include? response
end
rescue StandardError => e
Rails.logger.warn "cannot connect to #{url}"
Rails.logger.warn e
end
end
end

View File

@@ -1,5 +1,4 @@
require 'net/http'
require 'uri'
# frozen_string_literal: true
class Messenger
include Redmine::I18n
@@ -12,13 +11,13 @@ class Messenger
#
# Redmine::WikiFormatting.html_parser.to_text(text)
text = +text.to_s
text = text.to_s.dup
# @see https://api.slack.com/reference/surfaces/formatting#escaping
text.gsub!('&', '&amp;')
text.gsub!('<', '&lt;')
text.gsub!('>', '&gt;')
text.gsub! '&', '&amp;'
text.gsub! '<', '&lt;'
text.gsub! '>', '&gt;'
text
end
@@ -28,11 +27,11 @@ class Messenger
end
def speak(msg, channels, url, options)
url ||= RedmineMessenger.settings[:messenger_url]
url ||= RedmineMessenger.setting :messenger_url
return if url.blank? || channels.blank?
params = { text: msg, link_names: 1 }
username = textfield_for_project(options[:project], :messenger_username)
username = textfield_for_project options[:project], :messenger_username
params[:username] = username if username.present?
params[:attachments] = options[:attachment]&.any? ? [options[:attachment]] : []
icon = textfield_for_project options[:project], :messenger_icon
@@ -45,21 +44,8 @@ class Messenger
end
channels.each do |channel|
uri = URI(url)
params[:channel] = channel
http_options = { use_ssl: uri.scheme == 'https' }
http_options[:verify_mode] = OpenSSL::SSL::VERIFY_NONE unless RedmineMessenger.setting?(:messenger_verify_ssl)
begin
req = Net::HTTP::Post.new uri
req.set_form_data payload: params.to_json
Net::HTTP.start(uri.hostname, uri.port, http_options) do |http|
response = http.request req
Rails.logger.warn(response.inspect) unless [Net::HTTPSuccess, Net::HTTPRedirection, Net::HTTPOK].include? response
end
rescue StandardError => e
Rails.logger.warn "cannot connect to #{url}"
Rails.logger.warn e
end
MessengerDeliverJob.perform_later url, params
end
end
@@ -68,9 +54,9 @@ class Messenger
host = Regexp.last_match 2
port = Regexp.last_match 4
prefix = Regexp.last_match 5
Rails.application.routes.url_for(obj.event_url(host: host, protocol: Setting.protocol, port: port, script_name: prefix))
Rails.application.routes.url_for obj.event_url(host: host, protocol: Setting.protocol, port: port, script_name: prefix)
else
Rails.application.routes.url_for(obj.event_url(host: Setting.host_name, protocol: Setting.protocol, script_name: ''))
Rails.application.routes.url_for obj.event_url(host: Setting.host_name, protocol: Setting.protocol, script_name: '')
end
end
@@ -78,32 +64,32 @@ class Messenger
return if proj.blank?
# project based
pm = MessengerSetting.find_by project_id: proj.id
pm = proj.messenger_setting
return pm.messenger_url if !pm.nil? && pm.messenger_url.present?
# parent project based
parent_url = url_for_project proj.parent
return parent_url if parent_url.present?
# system based
return RedmineMessenger.settings[:messenger_url] if RedmineMessenger.settings[:messenger_url].present?
return RedmineMessenger.setting :messenger_url if RedmineMessenger.setting(:messenger_url).present?
nil
end
def project_url_markdown(project)
"[#{project.name}](#{object_url project})"
"<#{object_url project}|#{project.name}>"
end
def url_markdown(obj, name)
"[#{name}](#{object_url obj})"
"<#{object_url obj}|#{name}>"
end
def textfield_for_project(proj, config)
return if proj.blank?
# project based
pm = MessengerSetting.find_by project_id: proj.id
return pm.send(config) if !pm.nil? && pm.send(config).present?
pm = proj.messenger_setting
return pm.send config if !pm.nil? && pm.send(config).present?
default_textfield proj, config
end
@@ -112,7 +98,7 @@ class Messenger
# parent project based
parent_field = textfield_for_project proj.parent, config
return parent_field if parent_field.present?
return RedmineMessenger.settings[config] if RedmineMessenger.settings[config].present?
return RedmineMessenger.setting config if RedmineMessenger.setting(config).present?
''
end
@@ -121,7 +107,7 @@ class Messenger
return [] if proj.blank?
# project based
pm = MessengerSetting.find_by(project_id: proj.id)
pm = proj.messenger_setting
if !pm.nil? && pm.messenger_channel.present?
return [] if pm.messenger_channel == '-'
@@ -135,14 +121,14 @@ class Messenger
@setting_found = 0
# project based
pm = MessengerSetting.find_by(project_id: proj.id)
pm = proj.messenger_setting
unless pm.nil? || pm.send(config).zero?
@setting_found = 1
return false if pm.send(config) == 1
return true if pm.send(config) == 2
# 0 = use system based settings
end
default_project_setting(proj, config)
default_project_setting proj, config
end
def default_project_setting(proj, config)
@@ -151,7 +137,7 @@ class Messenger
return parent_setting if @setting_found == 1
end
# system based
return true if RedmineMessenger.settings[config].present? && RedmineMessenger.setting?(config)
return true if RedmineMessenger.setting(config).present? && RedmineMessenger.setting?(config)
false
end
@@ -159,16 +145,6 @@ class Messenger
def attachment_text_from_journal(journal)
obj = journal.details.detect { |j| j.prop_key == 'description' && j.property == 'attr' }
text = obj.value if obj.present?
if journal.notes.present?
if text.present?
text << "\n\n*#{l :label_comment}*\n"
text << journal.notes
else
text = journal.notes
end
end
text.present? ? markup_format(text) : nil
end
@@ -183,7 +159,7 @@ class Messenger
title = key
field_format = CustomField.find(detail.prop_key)&.field_format
value = IssuesController.helpers.format_value(detail.value, detail.custom_field) if detail.value.present?
value = IssuesController.helpers.format_value detail.value, detail.custom_field if detail.value.present?
end
elsif detail.property == 'attachment'
key = 'attachment'
@@ -191,7 +167,7 @@ class Messenger
value = detail.value.to_s
elsif detail.property == 'attr' &&
detail.prop_key == 'db_relation'
return { short: true } unless setting_for_project(prj, :post_db)
return { short: true } unless setting_for_project prj, :post_db
title = I18n.t :field_db_relation
if detail.value.present?
@@ -200,7 +176,7 @@ class Messenger
end
elsif detail.property == 'attr' &&
detail.prop_key == 'password_relation'
return { short: true } unless setting_for_project(prj, :post_password)
return { short: true } unless setting_for_project prj, :post_password
title = I18n.t :field_password_relation
if detail.value.present?
@@ -208,9 +184,12 @@ class Messenger
value = entry.present? ? entry.name : detail.value.to_s
end
else
key = detail.prop_key.to_s.sub('_id', '')
title = if key == 'parent'
key = detail.prop_key.to_s.sub '_id', ''
title = case key
when 'parent'
I18n.t "field_#{key}_issue"
when 'copied_from'
I18n.t "label_#{key}"
else
I18n.t "field_#{key}"
end
@@ -218,7 +197,6 @@ class Messenger
end
short = true
case key
when 'title', 'subject'
short = false
@@ -236,12 +214,12 @@ class Messenger
value = object_field_value IssuePriority, detail.value
when 'category'
value = object_field_value IssueCategory, detail.value
when 'assigned_to'
value = object_field_value User, detail.value
when 'assigned_to', 'author'
value = object_field_value Principal, detail.value
when 'fixed_version'
value = object_field_value Version, detail.value
when 'attachment'
attachment = Attachment.find(detail.prop_key)
attachment = Attachment.find_by id: detail.prop_key
value = if attachment.present?
escape = false
"<#{object_url attachment}|#{markup_format attachment.filename}>"
@@ -249,8 +227,8 @@ class Messenger
detail.prop_key.to_s
end
when 'parent'
issue = Issue.find detail.value
when 'parent', 'copied_from'
issue = Issue.find_by id: detail.value
value = if issue.present?
escape = false
"<#{object_url issue}|#{markup_format issue}>"
@@ -259,7 +237,7 @@ class Messenger
end
end
value = object_field_value(Version, detail.value) if detail.property == 'cf' && field_format == 'version'
value = object_field_value Version, detail.value if detail.property == 'cf' && field_format == 'version'
value = if value.present?
if escape
markup_format value
@@ -278,7 +256,7 @@ class Messenger
def mentions(project, text)
names = []
textfield_for_project(project, :default_mentions).split(',').each { |m| names.push m.strip }
names += extract_usernames(text) unless text.nil?
names += extract_usernames text unless text.nil?
names.present? ? " To: #{names.uniq.join ', '}" : nil
end
@@ -290,7 +268,8 @@ class Messenger
end
def extract_usernames(text)
text = '' if text.nil?
return [] if text.blank?
# messenger usernames may only contain lowercase letters, numbers,
# dashes, dots and underscores and must start with a letter or number.
text.scan(/@[a-z0-9][a-z0-9_\-.]*/).uniq
@@ -301,9 +280,9 @@ class Messenger
parent_channel = channels_for_project proj.parent
return parent_channel if parent_channel.present?
# system based
if RedmineMessenger.settings[:messenger_channel].present? &&
RedmineMessenger.settings[:messenger_channel] != '-'
return RedmineMessenger.settings[:messenger_channel].split(',').map!(&:strip).uniq
if RedmineMessenger.setting(:messenger_channel).present? &&
RedmineMessenger.setting(:messenger_channel) != '-'
return RedmineMessenger.setting(:messenger_channel).split(',').map!(&:strip).uniq
end
[]

View File

@@ -1,13 +1,15 @@
# frozen_string_literal: true
class MessengerSetting < ActiveRecord::Base
belongs_to :project
validates :messenger_url, url: { allow_blank: true, message: l(:error_messenger_invalid_url) }
validates :messenger_url, format: { with: URI::DEFAULT_PARSER.make_regexp(%w[http https]), allow_blank: true }
def self.find_or_create(p_id)
setting = MessengerSetting.find_by project_id: p_id
def self.find_or_create(project_id)
setting = MessengerSetting.find_by project_id: project_id
unless setting
setting = MessengerSetting.new
setting.project_id = p_id
setting.project_id = project_id
setting.save!
end

View File

@@ -1,7 +1,7 @@
p
= f.select mf, project_messenger_options(@messenger_setting.send(mf)), label: l("label_settings_#{mf}")
'
em.info[style="display: inline;"]
= l(:label_default)
em.info style="display: inline;"
= l :label_default
' :
= project_setting_messenger_default_value(mf)
= project_setting_messenger_default_value mf

View File

@@ -1,9 +1,9 @@
p
= f.text_field mf, size: size, label: l("label_settings_#{mf}")
em.info
= l(:label_messenger_project_text_field_info)
= l :label_messenger_project_text_field_info
| (
= l(:label_default)
= l :label_default
' :
= Messenger.default_textfield(@project, mf)
= Messenger.default_textfield @project, mf
| )

View File

@@ -1,78 +1,77 @@
= error_messages_for 'messenger_setting'
- @messenger_setting = MessengerSetting.find_or_create(@project.id)
- @messenger_setting = MessengerSetting.find_or_create @project.id
= labelled_form_for :setting,
@messenger_setting,
url: project_messenger_setting_path(project_id: @project),
method: :put,
class: 'tabular' do |f|
method: :put do |f|
fieldset#messenger_settings.box.tabular
legend = l(:label_messenger_outgoing_webhook)
legend = l :label_messenger_outgoing_webhook
- if User.current.admin?
.contextual
= link_to l(:label_administration), plugin_settings_path(id: 'redmine_messenger'), class: 'icon icon-settings'
.info = t(:messenger_settings_project_intro)
.info = t :messenger_settings_project_intro
br
p
= f.text_field :messenger_url, size: 60, label: l(:label_settings_messenger_url)
em.info
= l(:label_messenger_project_text_field_info)
= l :label_messenger_project_text_field_info
| (
= l(:label_messenger_default_not_visible)
= l :label_messenger_default_not_visible
| )
= render partial: 'messenger_settings/messenger_text', locals: { f: f, mf: :messenger_icon, size: 60 }
= render partial: 'messenger_settings/messenger_text', locals: { f: f, mf: :messenger_channel, size: 30 }
= render partial: 'messenger_settings/messenger_text', locals: { f: f, mf: :messenger_username, size: 30 }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :messenger_verify_ssl }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :messenger_direct_users_messages }
= render 'messenger_settings/messenger_text', f: f, mf: :messenger_icon, size: 60
= render 'messenger_settings/messenger_text', f: f, mf: :messenger_channel, size: 30
= render 'messenger_settings/messenger_text', f: f, mf: :messenger_username, size: 30
= render 'messenger_settings/messenger_select', f: f, mf: :messenger_verify_ssl
fieldset#messenger_settings.box.tabular
legend = l(:label_issue_plural)
.info = t(:messenger_issue_intro)
legend = l :label_issue_plural
.info = t :messenger_issue_intro
br
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :auto_mentions }
= render partial: 'messenger_settings/messenger_text', locals: { f: f, mf: :default_mentions, size: 30 }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :display_watchers }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_updates }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :new_include_description }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :updated_include_description }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_private_issues }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_private_notes }
= render 'messenger_settings/messenger_select', f: f, mf: :auto_mentions
= render 'messenger_settings/messenger_text', f: f, mf: :default_mentions, size: 30
= render 'messenger_settings/messenger_select', f: f, mf: :display_watchers
= render 'messenger_settings/messenger_select', f: f, mf: :post_updates
= render 'messenger_settings/messenger_select', f: f, mf: :new_include_description
= render 'messenger_settings/messenger_select', f: f, mf: :updated_include_description
= render 'messenger_settings/messenger_select', f: f, mf: :post_private_issues
= render 'messenger_settings/messenger_select', f: f, mf: :post_private_notes
= render 'messenger_settings/messenger_select', f: f, mf: :messenger_direct_users_messages
fieldset#messenger_settings.box.tabular
legend = l(:label_wiki)
.info = t(:messenger_wiki_intro)
legend = l :label_wiki
.info = t :messenger_wiki_intro
br
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_wiki }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_wiki_updates }
= render 'messenger_settings/messenger_select', f: f, mf: :post_wiki
= render 'messenger_settings/messenger_select', f: f, mf: :post_wiki_updates
- if RedmineMessenger::REDMINE_DB_SUPPORT && User.current.allowed_to?(:view_db_entries, @project)
fieldset#messenger_settings.box.tabular
legend = l(:field_db_entries)
.info = t(:messenger_db_intro)
legend = l :field_db_entries
.info = t :messenger_db_intro
br
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_db }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_db_updates }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_private_db }
= render 'messenger_settings/messenger_select', f: f, mf: :post_db
= render 'messenger_settings/messenger_select', f: f, mf: :post_db_updates
= render 'messenger_settings/messenger_select', f: f, mf: :post_private_db
- if RedmineMessenger::REDMINE_CONTACTS_SUPPORT && User.current.allowed_to?(:view_contacts, @project)
fieldset#messenger_settings.box.tabular
legend = l(:label_contact_plural)
.info = t(:messenger_contacts_intro)
legend = l :label_contact_plural
.info = t :messenger_contacts_intro
br
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_contact }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_contact_updates }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_private_contacts }
= render 'messenger_settings/messenger_select', f: f, mf: :post_contact
= render 'messenger_settings/messenger_select', f: f, mf: :post_contact_updates
= render 'messenger_settings/messenger_select', f: f, mf: :post_private_contacts
- if Redmine::Plugin.installed?('redmine_passwords') && User.current.allowed_to?(:view_passwords, @project)
fieldset#messenger_settings.box.tabular
legend = l(:field_passwords)
.info = t(:messenger_passwords_intro)
legend = l :label_password_plural
.info = t :messenger_passwords_intro
br
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_password }
= render partial: 'messenger_settings/messenger_select', locals: { f: f, mf: :post_password_updates }
= render 'messenger_settings/messenger_select', f: f, mf: :post_password
= render 'messenger_settings/messenger_select', f: f, mf: :post_password_updates
= submit_tag l(:button_save)

View File

@@ -1,110 +1,111 @@
.info = t(:messenger_settings_intro)
.info = t :messenger_settings_intro
br
fieldset#messenger_settings.box.tabular
legend = l(:label_messenger_outgoing_webhook)
legend = l :label_messenger_outgoing_webhook
p
= tag.label l(:label_settings_messenger_url)
= text_field_tag('settings[messenger_url]', @settings[:messenger_url], size: 60, placeholder: 'https://webhook.url')
em.info = t(:messenger_url_info_html)
label = l :label_settings_messenger_url
= text_field_tag 'settings[messenger_url]', @settings[:messenger_url], size: 60, placeholder: 'https://webhook.url'
em.info = t :messenger_url_info_html
p
= tag.label l(:label_settings_messenger_icon)
= text_field_tag('settings[messenger_icon]', @settings[:messenger_icon], size: 60)
label = l :label_settings_messenger_icon
= text_field_tag 'settings[messenger_icon]', @settings[:messenger_icon], size: 60
p
= tag.label l(:label_settings_messenger_channel)
= text_field_tag('settings[messenger_channel]', @settings[:messenger_channel], size: 30, placeholder: 'redmine')
em.info = t(:messenger_channel_info_html)
label = l :label_settings_messenger_channel
= text_field_tag 'settings[messenger_channel]', @settings[:messenger_channel], size: 30, placeholder: 'redmine'
em.info = t :messenger_channel_info_html
p
= tag.label l(:label_settings_messenger_username)
= text_field_tag('settings[messenger_username]', @settings[:messenger_username], size: 30)
label = l :label_settings_messenger_username
= text_field_tag 'settings[messenger_username]', @settings[:messenger_username], size: 30
p
= tag.label l(:label_settings_messenger_verify_ssl)
label = l :label_settings_messenger_verify_ssl
= check_box_tag 'settings[messenger_verify_ssl]', 1, @settings[:messenger_verify_ssl].to_i == 1
em.info = t(:messenger_verify_ssl_info_html)
p
= tag.label l(:label_settings_messenger_direct_users_messages)
= check_box_tag 'settings[messenger_direct_users_messages]', 1, @settings[:messenger_direct_users_messages].to_i == 1
em.info = t(:messenger_direct_users_messages_info_html)
em.info = t :messenger_verify_ssl_info_html
fieldset#messenger_settings.box.tabular
legend = l(:label_issue_plural)
.info = t(:messenger_issue_intro)
legend = l :label_issue_plural
.info = t :messenger_issue_intro
br
p
= tag.label l(:label_settings_auto_mentions)
label = l :label_settings_auto_mentions
= check_box_tag 'settings[auto_mentions]', 1, @settings[:auto_mentions].to_i == 1
p
= tag.label l(:label_settings_default_mentions)
= text_field_tag('settings[default_mentions]', @settings[:default_mentions], size: 30)
em.info = t(:default_mentionsl_info)
label = l :label_settings_default_mentions
= text_field_tag 'settings[default_mentions]', @settings[:default_mentions], size: 30
em.info = t :default_mentionsl_info
p
= tag.label l(:label_settings_display_watchers)
label = l :label_settings_display_watchers
= check_box_tag 'settings[display_watchers]', 1, @settings[:display_watchers].to_i == 1
p
= tag.label l(:label_settings_post_updates)
label = l :label_settings_post_updates
= check_box_tag 'settings[post_updates]', 1, @settings[:post_updates].to_i == 1
p
= tag.label l(:label_settings_new_include_description)
label = l :label_settings_new_include_description
= check_box_tag 'settings[new_include_description]', 1, @settings[:new_include_description].to_i == 1
p
= tag.label l(:label_settings_updated_include_description)
label = l :label_settings_updated_include_description
= check_box_tag 'settings[updated_include_description]', 1, @settings[:updated_include_description].to_i == 1
p
= tag.label l(:label_settings_post_private_issues)
label = l :label_settings_post_private_issues
= check_box_tag 'settings[post_private_issues]', 1, @settings[:post_private_issues].to_i == 1
p
= tag.label l(:label_settings_post_private_notes)
label = l :label_settings_post_private_notes
= check_box_tag 'settings[post_private_notes]', 1, @settings[:post_private_notes].to_i == 1
p
label = l :label_settings_messenger_direct_users_messages
= check_box_tag 'settings[messenger_direct_users_messages]', 1, @settings[:messenger_direct_users_messages].to_i == 1
em.info = t :messenger_direct_users_messages_info_html
fieldset#messenger_settings.box.tabular
legend = l(:label_wiki)
.info = t(:messenger_wiki_intro)
legend = l :label_wiki
.info = t :messenger_wiki_intro
br
p
= tag.label l(:label_settings_post_wiki)
label = l :label_settings_post_wiki
= check_box_tag 'settings[post_wiki]', 1, @settings[:post_wiki].to_i == 1
p
= tag.label l(:label_settings_post_wiki_updates)
label = l :label_settings_post_wiki_updates
= check_box_tag 'settings[post_wiki_updates]', 1, @settings[:post_wiki_updates].to_i == 1
- if RedmineMessenger::REDMINE_DB_SUPPORT
fieldset#messenger_settings.box.tabular
legend = l(:field_db_entries)
.info = t(:messenger_db_intro)
legend = l :field_db_entries
.info = t :messenger_db_intro
br
p
= tag.label l(:label_settings_post_db)
label = l :label_settings_post_db
= check_box_tag 'settings[post_db]', 1, @settings[:post_db].to_i == 1
p
= tag.label l(:label_settings_post_db_updates)
label = l :label_settings_post_db_updates
= check_box_tag 'settings[post_db_updates]', 1, @settings[:post_db_updates].to_i == 1
p
= tag.label l(:label_settings_post_private_db)
label = l :label_settings_post_private_db
= check_box_tag 'settings[post_private_db]', 1, @settings[:post_private_db].to_i == 1
- if RedmineMessenger::REDMINE_CONTACTS_SUPPORT
fieldset#messenger_settings.box.tabular
legend = l(:label_contact_plural)
.info = t(:messenger_contacts_intro)
legend = l :label_contact_plural
.info = t :messenger_contacts_intro
br
p
= tag.label l(:label_settings_post_contact)
label = l :label_settings_post_contact
= check_box_tag 'settings[post_contact]', 1, @settings[:post_contact].to_i == 1
p
= tag.label l(:label_settings_post_contact_updates)
label = l :label_settings_post_contact_updates
= check_box_tag 'settings[post_contact_updates]', 1, @settings[:post_contact_updates].to_i == 1
p
= tag.label l(:label_settings_post_private_contacts)
label = l :label_settings_post_private_contacts
= check_box_tag 'settings[post_private_contacts]', 1, @settings[:post_private_contacts].to_i == 1
- if Redmine::Plugin.installed?('redmine_passwords')
- if Redmine::Plugin.installed? 'redmine_passwords'
fieldset#messenger_settings.box.tabular
legend = l(:field_passwords)
.info = t(:messenger_passwords_intro)
legend = l :label_password_plural
.info = t :messenger_passwords_intro
br
p
= tag.label l(:label_settings_post_password)
label = l :label_settings_post_password
= check_box_tag 'settings[post_password]', 1, @settings[:post_password].to_i == 1
p
= tag.label l(:label_settings_post_password_updates)
label = l :label_settings_post_password_updates
= check_box_tag 'settings[post_password_updates]', 1, @settings[:post_password_updates].to_i == 1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 214 KiB

After

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

View File

@@ -1,7 +1,6 @@
# German strings
de:
default_mentionsl_info: Benutzer, die immer mit Mentions benachrichtet werden sollen. Mehrere Namen können mit Komma getrennt angegeben werden (z.B. @all, @here).
error_messenger_invalid_url: "ist keine gültige URL"
label_messenger_contact_created: "%{project_url} - Kontakt %{url} erstellt von *%{user}*"
label_messenger_contact_updated: "%{project_url} - Kontakt %{url} aktualisiert von *%{user}*"
label_messenger_db_entry_created: "%{project_url} - DB Eintrag %{url} erstellt von *%{user}*"
@@ -10,8 +9,8 @@ de:
label_messenger_issue_created: "%{project_url} - Ticket %{url} erstellt von *%{user}*"
label_messenger_issue_updated: "%{project_url} - Ticket %{url} aktualisiert von *%{user}*"
label_messenger_outgoing_webhook: Ausgehender Webhook
label_messenger_password_created: "%{project_url} - Kennwort %{url} erstellt von *%{user}*"
label_messenger_password_updated: "%{project_url} - Kennwort %{url} aktualisiert von *%{user}*"
label_messenger_password_created: "%{project_url} - Passwort %{url} erstellt von *%{user}*"
label_messenger_password_updated: "%{project_url} - Passwort %{url} aktualisiert von *%{user}*"
label_messenger_project_text_field_info: Leer lassen für Systemstandard.
label_messenger_setting: Messenger Einstellung
label_messenger_settings_default: Standardeinstellung

View File

@@ -1,7 +1,6 @@
# English strings
en:
default_mentionsl_info: Default people to notify, comma separated (e.g. @all, @here)
error_messenger_invalid_url: is not a valid URL
label_messenger_contact_created: "%{project_url} - Contact %{url} created by *%{user}*"
label_messenger_contact_updated: "%{project_url} - Contact %{url} updated by *%{user}*"
label_messenger_db_entry_created: "%{project_url} - DB entry %{url} created by *%{user}*"
@@ -44,7 +43,7 @@ en:
label_settings_post_wiki_updates: Wiki updates?
label_settings_post_wiki: Post Wiki added?
label_settings_updated_include_description: Description in update issue?
messenger_channel_info_html: 'Here you have to specify the channel, which should be used. You can define multible channels, seperated by comma'
messenger_channel_info_html: 'Here you have to specify the channel, which should be used. You can define multiple channels, seperated by comma'
messenger_contacts_intro: Activate the changes for Issues that should be sent to the pre-defined Messenger channel.
messenger_db_intro: Activate the changes for DB that should be sent to the pre-defined Messenger channel.
messenger_issue_intro: Activate the changes for Issues that should be sent to the pre-defined Messenger channel.
@@ -53,6 +52,6 @@ en:
messenger_settings_project_intro: "If you left empty the Messenger URL in the administration area in case to be not globally notified by all project changes you can configure your Messenger URL in the project settings."
messenger_url_info_html: 'Generate an <a target="_blank" href="https://github.com/AlphaNodes/redmine_messenger#prepare-your-messenger-service">Incoming WebHook</a> URL from the messenger service. Leave it empty, if you only want to activate specific projects with project based settings'
messenger_verify_ssl_info_html: 'If your Messenger service uses an invalid or self-signed SSL certificate, disable it.'
messenger_direct_users_messages_info_html: 'If enabled Messenger will post http requests to each user as channel(direct message in RocketChat) along with post in channel'
messenger_direct_users_messages_info_html: 'If enabled Messenger will post http requests to each user as channel (direct message in RocketChat) along with post in channel'
messenger_wiki_intro: Activate the changes for Wikis that should be sent to the pre-defined Messenger channel.
permission_manage_messenger: Manage messenger

View File

@@ -1,7 +1,6 @@
# French strings
fr:
default_mentionsl_info: Personnes à notifier par défaut, séparées par des virgules (@all, @here)
error_messenger_invalid_url: n'est pas une URL valide
label_messenger_contact_created: "%{project_url} - Le contact %{url} créé par *%{user}*"
label_messenger_contact_updated: "%{project_url} - Le contact %{url} mis à jour par *%{user}*"
label_messenger_db_entry_created: "%{project_url} - Entrée de base de données %{url} créée par *%{user}*"

View File

@@ -1,7 +1,6 @@
# Japanese strings
ja:
default_mentionsl_info: Default people to notify, comma separated (e.g. @all, @here)
error_messenger_invalid_url: is not a valid URL
label_messenger_contact_created: "%{project_url} - コンタクト %{url} が *%{user}* によって作成されました。"
label_messenger_contact_updated: "%{project_url} - コンタクト %{url} が*%{user}* によって更新されました。"
label_messenger_db_entry_created: "%{project_url} - DB entry %{url} created by *%{user}*"

View File

@@ -1,7 +1,6 @@
# Korean strings
ko:
default_mentionsl_info: 알림을 받을 기본 사용자를 나타내며, 쉼표로 구분 (e.g. @all, @here)
error_messenger_invalid_url: 유효한 URL이 아님
label_messenger_contact_created: "%{project_url} - *%{user}*님이 연락처(%{url})를 만들었습니다."
label_messenger_contact_updated: "%{project_url} - *%{user}*님이 연락처(%{url})를 수정했습니다."
label_messenger_db_entry_created: "%{project_url} - *%{user}*님이 데이터베이스 항목(%{url})을 만들었습니다."

57
config/locales/nl.yml Normal file
View File

@@ -0,0 +1,57 @@
# Dutch strings
nl:
default_mentionsl_info: Standaard gebruikers om op de hoogte te stellen, gescheiden door een komma (e.g. @all, @here)
label_messenger_contact_created: "%{project_url} - Contact %{url} aangemaakt door *%{user}*"
label_messenger_contact_updated: "%{project_url} - Contact %{url} bijgewerkt door *%{user}*"
label_messenger_db_entry_created: "%{project_url} - DB entry %{url} aangemaakt door *%{user}*"
label_messenger_db_entry_updated: "%{project_url} - DB entry %{url} bijgewerkt door *%{user}*"
label_messenger_default_not_visible: Standaardwaarde is niet zichtbaar vanwege beveiligingsredenen.
label_messenger_issue_created: "%{project_url} - Issue %{url} aangemaakt door *%{user}*"
label_messenger_issue_updated: "%{project_url} - Issue %{url} bijgewerkt door *%{user}*"
label_messenger_outgoing_webhook: Uitgaande Webhook
label_messenger_password_created: "%{project_url} - Wachtwoord %{url} aangemaakt door *%{user}*"
label_messenger_password_updated: "%{project_url} - Wachtwoord %{url} bijgewerkt door *%{user}*"
label_messenger_project_text_field_info: Laat leeg voor systeeminstelling.
label_messenger_setting: Messenger Instellingen
label_messenger_settings_default: Systeeminstelling
label_messenger_settings_disabled: Uitgeschakeld
label_messenger_settings_enabled: Ingeschakeld
label_messenger_wiki_created: "%{project_url} - Wiki %{url} aangemaakt door *%{user}*"
label_messenger_wiki_updated: "%{project_url} - Wiki %{url} bijgewerkt door *%{user}*"
label_messenger: Messenger
label_settings_auto_mentions: Zet namen om in mentions?
label_settings_default_mentions: Standaardgebuikers voor mentions
label_settings_display_watchers: Geef watchers weer?
label_settings_messenger_channel: Messenger Kanaal
label_settings_messenger_icon: Messenger Icoon
label_settings_messenger_url: Messenger URL
label_settings_messenger_username: Messenger gebruikersnaam
label_settings_messenger_verify_ssl: Verifieer SSL
label_settings_messenger_direct_users_messages: Stuur directe berichten
label_settings_new_include_description: Nieuwe issue beschrijving?
label_settings_post_contact_updates: Contact bijwerkingen?
label_settings_post_contact: Contact aangemaakt?
label_settings_post_db_updates: DB entry bijwerkingen?
label_settings_post_db: DB entry toegevoegd?
label_settings_post_password_updates: Wachtwoord bijwerkingen?
label_settings_post_password: Wachtwoord toegevoegd?
label_settings_post_private_contacts: Private contacten?
label_settings_post_private_db: Private DB entries?
label_settings_post_private_issues: Private issue bijwerkingen?
label_settings_post_private_notes: Private notes bijwerkingen?
label_settings_post_updates: Issue bijwerkingen?
label_settings_post_wiki_updates: Wiki bijwerkingen?
label_settings_post_wiki: Wiki toegevoegd?
label_settings_updated_include_description: Beschrijving in bijwerking issue?
messenger_channel_info_html: 'Hier kun je het kanaal opgeven dat gebruikt moet worden. Meerdere kanalen kunnen worden gebruikt, gescheiden door een komma'
messenger_contacts_intro: Activeer de bijwerkingen voor Issues die gestuurd moeten worden naar het van tevoren gekozen kanaal.
messenger_db_intro: Activeer de bijwerkingen van de database die gestuurd moeten worden naar het van tevoren gekozen kanaal.
messenger_issue_intro: Activeer de bijwerkingen voor Issues die gestuurd moeten worden naar het van tevoren gekozen kanaal.
messenger_passwords_intro: Activeer de bijwerkingen voor wachtwoorden die gestuurd moeten worden naar het van tevoren gekozen kanaal.
messenger_settings_intro: "Laat de Messenger-URL in het beheergedeelte leeg om geen berichten van Redmine naar de Messenger te sturen. Het maakt niet uit wat je hier nog meer hebt geconfigureerd. Als je berichten van alle Redmine-projecten naar de Messenger wilt sturen, vul dan de URL in. De berichten worden naar het specifieke kanaal gestuurd. Als je alleen door enkele van de projecten (niet alle) op de hoogte wilt worden gehouden, laat u de messenger-URL hier leeg en gebruik de specifieke projectconfiguratie."
messenger_settings_project_intro: "Als u de Messenger-URL in het beheergedeelte leeg hebt gelaten voor het geval je niet wereldwijd op de hoogte wordt gesteld door alle projectwijzigingen, kun je de Messenger-URL configureren in de projectinstellingen."
messenger_url_info_html: 'Genereer een <a target="_blank" href="https://github.com/AlphaNodes/redmine_messenger#prepare-your-messenger-service">Inkomende WebHook</a> URL van de messenger service. Laat het leeg als u alleen specifieke projecten wilt activeren met projectgebaseerde instellingen'
messenger_verify_ssl_info_html: 'Als je Messenger-service een ongeldig of zelfondertekend SSL-certificaat gebruikt, schakel deze checkbox uit.'
messenger_direct_users_messages_info_html: 'Indien ingeschakeld, zal Messenger http-verzoeken naar elke gebruiker plaatsen als kanaal (direct bericht in RocketChat) samen met een bericht in het kanaal'
messenger_wiki_intro: "Activeer de wijzigingen voor Wiki's die naar het vooraf gedefinieerde Messenger-kanaal moeten worden verzonden."
permission_manage_messenger: Beheer messenger

57
config/locales/pt-BR.yml Normal file
View File

@@ -0,0 +1,57 @@
# Brazilian Portuguese strings
pt-BR:
default_mentionsl_info: "Pessoas a notificar, separadas por vírgula (ex: @all, @here)"
label_messenger_contact_created: "%{project_url} - Contato %{url} criado por *%{user}*"
label_messenger_contact_updated: "%{project_url} - Contato %{url} atualizado por *%{user}*"
label_messenger_db_entry_created: "%{project_url} - Entrada de dado %{url} criada por *%{user}*"
label_messenger_db_entry_updated: "%{project_url} - Entrada de dado %{url} editada por *%{user}*"
label_messenger_default_not_visible: Configuração padrão não é viível por razões de segurança.
label_messenger_issue_created: "%{project_url} - Tarefa %{url} criada por *%{user}*"
label_messenger_issue_updated: "%{project_url} - Tarefa %{url} editada por *%{user}*"
label_messenger_outgoing_webhook: Webhook de saída
label_messenger_password_created: "%{project_url} - Senha %{url} criada por *%{user}*"
label_messenger_password_updated: "%{project_url} - Password %{url} updated by *%{user}*"
label_messenger_project_text_field_info: Deixe em branco para usar o padrão.
label_messenger_setting: Configurações do Messenger
label_messenger_settings_default: Configurações Padrão
label_messenger_settings_disabled: Desabilitado
label_messenger_settings_enabled: Habilitado
label_messenger_wiki_created: "%{project_url} - Wiki %{url} criado por *%{user}*"
label_messenger_wiki_updated: "%{project_url} - Wiki %{url} criado por *%{user}*"
label_messenger: Messenger
label_settings_auto_mentions: Converter nomes em menções?
label_settings_default_mentions: Pessoas padrão para menções
label_settings_display_watchers: Mostrar observadores?
label_settings_messenger_channel: Messenger - Canal
label_settings_messenger_icon: Messenger - Ícone
label_settings_messenger_url: Messenger - URL
label_settings_messenger_username: Messenger - nome de usuário
label_settings_messenger_verify_ssl: Verificar SSL
label_settings_messenger_direct_users_messages: Enviar mensagens diretas
label_settings_new_include_description: Descrição de novas tarefas?
label_settings_post_contact_updates: Edições de contato?
label_settings_post_contact: Contato adicionado?
label_settings_post_db_updates: Modificações de entrada BD?
label_settings_post_db: Nova entrada no BD?
label_settings_post_password_updates: Modificações de senha?
label_settings_post_password: Nova senha?
label_settings_post_private_contacts: Contatos privados?
label_settings_post_private_db: Entradas privadas BD?
label_settings_post_private_issues: Modificações em tarefas privadas?
label_settings_post_private_notes: Modificações em notas privadas?
label_settings_post_updates: Atualizações de tarefa?
label_settings_post_wiki_updates: Atualizações de Wiki?
label_settings_post_wiki: Novo post no Wiki?
label_settings_updated_include_description: Descrição em atualização de tarefa?
messenger_channel_info_html: 'Aqui você precisa especificar o canal a ser usado. Você pode definir múltiplos canais, separados por vírgula'
messenger_contacts_intro: Ative as modificações de Tarefas que devem ser enviadas para o canal predefinido no Messenger.
messenger_db_intro: Ative as modificações de Tarefas que devem ser enviadas para o canal predefinido no Messenger.
messenger_issue_intro: Ative as modificações de Tarefas que devem ser enviadas para o canal predefinido no Messenger.
messenger_passwords_intro: Ative as modificações de Senha que devem ser enviadas para o canal predefinido no Messenger.
messenger_settings_intro: "Deixe o campo Messenger URL vazio na área de administração para não enviar mensagens do Redmine para o Messenger, independente do que mais você tenha configurado. Caso deseje enviar mensagens de todos projetos do Redmine para o Messenger, informe a URL. As mensagens serão enviadas para o canal especificado. Se você só deseja ser notificado sobre algum(ns) projeto(s) (não todos) deixe o campo URL vazio aqui e vá para as configurações específicas do(s) projeto(s)."
messenger_settings_project_intro: "Se você deixar o campo Messenger URL vazio na área de administração para não ser notificado globalmente sobre todos os projetos, você pode configurar a Messenger URL nas configurações do(s) projeto(s)."
messenger_url_info_html: 'Gere uma URL <a target="_blank" href="https://github.com/AlphaNodes/redmine_messenger#prepare-your-messenger-service">Incoming WebHook</a> a partir do serviço de mensagens. Deixe em branco se você deseja ativar somente projetos específicos, com base nas configurações de projeto'
messenger_verify_ssl_info_html: 'Se o seu serviço Messenger usa um ceftificado SSL inválido ou auto assinado, desabilite.'
messenger_direct_users_messages_info_html: 'Se habilitado, o Messenger fará requisições http post para cada usuário como como um canal (mensagem direta no RocketChat) juntamente ao post no canal'
messenger_wiki_intro: Ative as modificações de Wikis que devem ser enviadas para o canal predefinido no Messenger.
permission_manage_messenger: Gerenciar messenger

View File

@@ -1,8 +1,7 @@
# Plugin's routes
# See: http://guides.rubyonrails.org/routing.html
# frozen_string_literal: true
# Don't create routes for repositories resources with only: []
# do not override Redmine's routes.
resources :projects, only: [] do
resource :messenger_setting, only: %i[show update]
Rails.application.routes.draw do
resources :projects, only: [] do
resource :messenger_setting, only: %i[show update]
end
end

26
config/settings.yml Normal file
View File

@@ -0,0 +1,26 @@
---
messenger_url: ''
messenger_icon: 'https://raw.githubusercontent.com/alphanodes/redmine_messenger/master/assets/images/icon.png'
messenger_channel: 'redmine'
messenger_username: 'robot'
messenger_verify_ssl: 1
messenger_direct_users_messages: 0
auto_mentions: 0
default_mentions: ''
display_watchers: 0
post_updates: 1
new_include_description: 1
updated_include_description: 1
post_private_contacts: 0
post_private_db: 0
post_private_issues: 0
post_private_notes: 0
post_wiki: 0
post_wiki_updates: 0
post_db: 0
post_db_updates: 0
post_contact: 0
post_contact_updates: 0
post_password: 0
post_password_updates: 0

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateMessengerSettings < ActiveRecord::Migration[4.2]
def change
create_table :messenger_settings do |t|

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddDefaultMentions < ActiveRecord::Migration[4.2]
def change
add_column :messenger_settings, :default_mentions, :string

View File

@@ -1,6 +1,10 @@
# frozen_string_literal: true
class AddPrivateSettings < ActiveRecord::Migration[4.2]
def change
add_column :messenger_settings, :post_private_contacts, :integer, default: 0, null: false
add_column :messenger_settings, :post_private_db, :integer, default: 0, null: false
change_table :messenger_settings, bulk: true do |t|
t.integer :post_private_contacts, default: 0, null: false
t.integer :post_private_db, default: 0, null: false
end
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddDirectMessages < ActiveRecord::Migration[4.2]
def change
add_column :messenger_settings, :messenger_direct_users_messages, :integer, default: 0, null: false

40
init.rb
View File

@@ -1,4 +1,6 @@
raise "\n\033[31mredmine_messenger requires ruby 2.4 or newer. Please update your ruby version.\033[0m" if RUBY_VERSION < '2.4'
# frozen_string_literal: true
loader = RedminePluginKit::Loader.new plugin_id: 'redmine_messenger'
Redmine::Plugin.register :redmine_messenger do
name 'Redmine Messenger'
@@ -6,40 +8,14 @@ Redmine::Plugin.register :redmine_messenger do
url 'https://github.com/alphanodes/redmine_messenger'
author_url 'https://alphanodes.com/'
description 'Messenger integration for Slack, Discord, Rocketchat and Mattermost support'
version '1.0.7'
version RedmineMessenger::VERSION
requires_redmine version_or_higher: '4.0.0'
requires_redmine version_or_higher: '4.2.0'
permission :manage_messenger, projects: :settings, messenger_settings: :update
settings default: {
messenger_url: '',
messenger_icon: 'https://raw.githubusercontent.com/alphanodes/redmine_messenger/master/assets/images/icon.png',
messenger_channel: 'redmine',
messenger_username: 'robot',
messenger_verify_ssl: '1',
messenger_direct_users_messages: '0',
auto_mentions: '0',
default_mentions: '',
display_watchers: '0',
post_updates: '1',
new_include_description: '1',
updated_include_description: '1',
post_private_contacts: '0',
post_private_db: '0',
post_private_issues: '0',
post_private_notes: '0',
post_wiki: '0',
post_wiki_updates: '0',
post_db: '0',
post_db_updates: '0',
post_contact: '0',
post_contact_updates: '0',
post_password: '0',
post_password_updates: '0'
}, partial: 'settings/messenger_settings'
settings default: loader.default_settings, partial: 'settings/messenger_settings'
end
Rails.configuration.to_prepare do
RedmineMessenger.setup
end
RedminePluginKit::Loader.persisting { loader.load_model_hooks! }
RedminePluginKit::Loader.to_prepare { RedmineMessenger.setup! } if Rails.version < '6.0'

View File

@@ -1,41 +1,33 @@
# frozen_string_literal: true
module RedmineMessenger
REDMINE_CONTACTS_SUPPORT = Redmine::Plugin.installed?('redmine_contacts') ? true : false
REDMINE_DB_SUPPORT = Redmine::Plugin.installed?('redmine_db') ? true : false
# this does not work at the moment, because redmine loads passwords after messener plugin
REDMINE_PASSWORDS_SUPPORT = Redmine::Plugin.installed?('redmine_passwords') ? true : false
VERSION = '1.0.14'
REDMINE_CONTACTS_SUPPORT = Redmine::Plugin.installed? 'redmine_contacts'
REDMINE_DB_SUPPORT = Redmine::Plugin.installed? 'redmine_db'
include RedminePluginKit::PluginBase
class << self
private
def setup
# Patches
Issue.include RedmineMessenger::Patches::IssuePatch
WikiPage.include RedmineMessenger::Patches::WikiPagePatch
ProjectsController.send :helper, MessengerProjectsHelper
Contact.include(RedmineMessenger::Patches::ContactPatch) if RedmineMessenger::REDMINE_CONTACTS_SUPPORT
DbEntry.include(RedmineMessenger::Patches::DbEntryPatch) if RedmineMessenger::REDMINE_DB_SUPPORT
Password.include(RedmineMessenger::Patches::PasswordPatch) if Redmine::Plugin.installed?('redmine_passwords')
loader.add_patch %w[Issue
Project
WikiPage]
loader.add_patch 'Contact' if RedmineMessenger::REDMINE_CONTACTS_SUPPORT
loader.add_patch 'DbEntry' if RedmineMessenger::REDMINE_DB_SUPPORT
loader.add_patch 'Password' if Redmine::Plugin.installed? 'redmine_passwords'
# Helper
loader.add_helper [{ controller: 'Projects', helper: 'MessengerProjects' }]
# Global helpers
ActionView::Base.include RedmineMessenger::Helpers
loader.add_global_helper RedmineMessenger::Helpers
# Hooks
require_dependency 'redmine_messenger/hooks'
end
def settings
if Setting[:plugin_redmine_messenger].class == Hash
new_settings = ActiveSupport::HashWithIndifferentAccess.new(Setting[:plugin_redmine_messenger])
Setting.plugin_redmine_messenger = new_settings
new_settings
else
# Rails 5 uses ActiveSupport::HashWithIndifferentAccess
Setting[:plugin_redmine_messenger]
end
end
def setting?(value)
return true if settings[value].to_i == 1
false
# Apply patches and helper
loader.apply!
end
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module RedmineMessenger
module Helpers
def project_messenger_options(active)
@@ -7,7 +9,7 @@ module RedmineMessenger
end
def project_setting_messenger_default_value(value)
if Messenger.default_project_setting(@project, value)
if Messenger.default_project_setting @project, value
l :label_messenger_settings_enabled
else
l :label_messenger_settings_disabled

View File

@@ -1,55 +0,0 @@
module RedmineMessenger
class MessengerListener < Redmine::Hook::Listener
def model_changeset_scan_commit_for_issue_ids_pre_issue_update(context = {})
issue = context[:issue]
journal = issue.current_journal
changeset = context[:changeset]
channels = Messenger.channels_for_project issue.project
url = Messenger.url_for_project issue.project
return unless channels.present? && url && issue.changes.any? && Messenger.setting_for_project(issue.project, :post_updates)
return if issue.is_private? && !Messenger.setting_for_project(issue.project, :post_private_issues)
msg = "[#{Messenger.markup_format issue.project}]" \
" #{Messenger.markup_format journal.user.to_s} updated <#{Messenger.object_url issue}|#{Messenger.markup_format issue}>"
repository = changeset.repository
if Setting.host_name.to_s =~ %r{/\A(https?://)?(.+?)(:(\d+))?(/.+)?\z/i}
host = Regexp.last_match(2)
port = Regexp.last_match(4)
prefix = Regexp.last_match(5)
revision_url = Rails.application.routes.url_for(
controller: 'repositories',
action: 'revision',
id: repository.project,
repository_id: repository.identifier_param,
rev: changeset.revision,
host: host,
protocol: Setting.protocol,
port: port,
script_name: prefix
)
else
revision_url = Rails.application.routes.url_for(
controller: 'repositories',
action: 'revision',
id: repository.project,
repository_id: repository.identifier_param,
rev: changeset.revision,
host: Setting.host_name,
protocol: Setting.protocol
)
end
attachment = {}
attachment[:text] = ll(Setting.default_language,
:text_status_changed_by_changeset,
"<#{revision_url}|#{Messenger.markup_format changeset.comments}>")
attachment[:fields] = journal.details.map { |d| Messenger.detail_to_field d }
Messenger.speak msg, channels, url, attachment: attachment, project: repository.project
end
end
end

View File

@@ -0,0 +1,65 @@
# frozen_string_literal: true
module RedmineMessenger
module Hooks
class ModelHook < Redmine::Hook::Listener
def after_plugins_loaded(_context = {})
return if Rails.version < '6.0'
RedmineMessenger.setup!
end
def model_changeset_scan_commit_for_issue_ids_pre_issue_update(context = {})
issue = context[:issue]
journal = issue.current_journal
changeset = context[:changeset]
channels = Messenger.channels_for_project issue.project
url = Messenger.url_for_project issue.project
return unless channels.present? && url && issue.changes.any? && Messenger.setting_for_project(issue.project, :post_updates)
return if issue.is_private? && !Messenger.setting_for_project(issue.project, :post_private_issues)
msg = "[#{Messenger.markup_format issue.project}] " \
"#{Messenger.markup_format journal.user.to_s} updated <#{Messenger.object_url issue}|#{Messenger.markup_format issue}>"
repository = changeset.repository
if Setting.host_name.to_s =~ %r{/\A(https?://)?(.+?)(:(\d+))?(/.+)?\z/i}
host = Regexp.last_match 2
port = Regexp.last_match 4
prefix = Regexp.last_match 5
revision_url = Rails.application.routes.url_for(
controller: 'repositories',
action: 'revision',
id: repository.project,
repository_id: repository.identifier_param,
rev: changeset.revision,
host: host,
protocol: Setting.protocol,
port: port,
script_name: prefix
)
else
revision_url = Rails.application.routes.url_for(
controller: 'repositories',
action: 'revision',
id: repository.project,
repository_id: repository.identifier_param,
rev: changeset.revision,
host: Setting.host_name,
protocol: Setting.protocol
)
end
attachment = {}
attachment[:text] = ll(Setting.default_language,
:text_status_changed_by_changeset,
"<#{revision_url}|#{Messenger.markup_format changeset.comments}>")
attachment[:fields] = journal.details.map { |d| Messenger.detail_to_field d }
Messenger.speak msg, channels, url, attachment: attachment, project: repository.project
end
end
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module RedmineMessenger
module Patches
module ContactPatch
@@ -15,36 +17,46 @@ module RedmineMessenger
return unless Messenger.setting_for_project project, :post_contact
return if is_private? && !Messenger.setting_for_project(project, :post_private_contacts)
set_language_if_valid Setting.default_language
channels = Messenger.channels_for_project project
url = Messenger.url_for_project project
return unless channels.present? && url
Messenger.speak l(:label_messenger_contact_created,
project_url: Messenger.project_url_markdown(project),
url: Messenger.url_markdown(self, name),
user: User.current),
channels, url, project: project
initial_language = ::I18n.locale
begin
set_language_if_valid Setting.default_language
Messenger.speak l(:label_messenger_contact_created,
project_url: Messenger.project_url_markdown(project),
url: Messenger.url_markdown(self, name),
user: User.current),
channels, url, project: project
ensure
::I18n.locale = initial_language
end
end
def send_messenger_update
return unless Messenger.setting_for_project project, :post_contact_updates
return if is_private? && !Messenger.setting_for_project(project, :post_private_contacts)
set_language_if_valid Setting.default_language
channels = Messenger.channels_for_project project
url = Messenger.url_for_project project
return unless channels.present? && url
Messenger.speak l(:label_messenger_contact_updated,
project_url: Messenger.project_url_markdown(project),
url: Messenger.url_markdown(self, name),
user: User.current),
channels, url, project: project
initial_language = ::I18n.locale
begin
set_language_if_valid Setting.default_language
Messenger.speak l(:label_messenger_contact_updated,
project_url: Messenger.project_url_markdown(project),
url: Messenger.url_markdown(self, name),
user: User.current),
channels, url, project: project
ensure
::I18n.locale = initial_language
end
end
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module RedmineMessenger
module Patches
module DbEntryPatch
@@ -15,36 +17,46 @@ module RedmineMessenger
return unless Messenger.setting_for_project project, :post_db
return if is_private? && !Messenger.setting_for_project(project, :post_private_db)
set_language_if_valid Setting.default_language
channels = Messenger.channels_for_project project
url = Messenger.url_for_project project
return unless channels.present? && url
Messenger.speak l(:label_messenger_db_entry_created,
project_url: Messenger.project_url_markdown(project),
url: Messenger.url_markdown(self, name),
user: User.current),
channels, url, project: project
initial_language = ::I18n.locale
begin
set_language_if_valid Setting.default_language
Messenger.speak l(:label_messenger_db_entry_created,
project_url: Messenger.project_url_markdown(project),
url: Messenger.url_markdown(self, name),
user: User.current),
channels, url, project: project
ensure
::I18n.locale = initial_language
end
end
def send_messenger_update
return unless Messenger.setting_for_project project, :post_db_updates
return if is_private? && !Messenger.setting_for_project(project, :post_private_db)
set_language_if_valid Setting.default_language
channels = Messenger.channels_for_project project
url = Messenger.url_for_project project
return unless channels.present? && url
Messenger.speak l(:label_messenger_db_entry_updated,
project_url: Messenger.project_url_markdown(project),
url: Messenger.url_markdown(self, name),
user: User.current),
channels, url, project: project
initial_language = ::I18n.locale
begin
set_language_if_valid Setting.default_language
Messenger.speak l(:label_messenger_db_entry_updated,
project_url: Messenger.project_url_markdown(project),
url: Messenger.url_markdown(self, name),
user: User.current),
channels, url, project: project
ensure
::I18n.locale = initial_language
end
end
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module RedmineMessenger
module Patches
module IssuePatch
@@ -15,52 +17,57 @@ module RedmineMessenger
channels = Messenger.channels_for_project project
url = Messenger.url_for_project project
if Messenger.setting_for_project(project, :messenger_direct_users_messages)
notified_users.each do |user|
channels.append "@#{user.login}" if user.login != author.login
if Messenger.setting_for_project project, :messenger_direct_users_messages
messenger_to_be_notified.each do |user|
channels.append "@#{user.login}" unless user == author
end
end
return unless channels.present? && url
return if is_private? && !Messenger.setting_for_project(project, :post_private_issues)
set_language_if_valid Setting.default_language
initial_language = ::I18n.locale
begin
set_language_if_valid Setting.default_language
attachment = {}
if description.present? && Messenger.setting_for_project(project, :new_include_description)
attachment[:text] = Messenger.markup_format description
end
attachment[:fields] = [{ title: I18n.t(:field_status),
value: Messenger.markup_format(status.to_s),
short: true },
{ title: I18n.t(:field_priority),
value: Messenger.markup_format(priority.to_s),
short: true }]
if assigned_to.present?
attachment[:fields] << { title: I18n.t(:field_assigned_to),
value: Messenger.markup_format(assigned_to.to_s),
short: true }
end
attachment = {}
if description.present? && Messenger.setting_for_project(project, :new_include_description)
attachment[:text] = Messenger.markup_format description
end
attachment[:fields] = [{ title: I18n.t(:field_status),
value: Messenger.markup_format(status.to_s),
short: true },
{ title: I18n.t(:field_priority),
value: Messenger.markup_format(priority.to_s),
short: true }]
if assigned_to.present?
attachment[:fields] << { title: I18n.t(:field_assigned_to),
value: Messenger.markup_format(assigned_to.to_s),
short: true }
end
attachments.each do |att|
attachment[:fields] << { title: I18n.t(:label_attachment),
value: "<#{Messenger.object_url att}|#{ERB::Util.html_escape att.filename}>",
short: true }
end
attachments.each do |att|
attachment[:fields] << { title: I18n.t(:label_attachment),
value: "<#{Messenger.object_url att}|#{ERB::Util.html_escape att.filename}>",
short: true }
end
if RedmineMessenger.setting?(:display_watchers) && watcher_users.count.positive?
attachment[:fields] << {
title: I18n.t(:field_watcher),
value: Messenger.markup_format(watcher_users.join(', ')),
short: true
}
end
if RedmineMessenger.setting?(:display_watchers) && watcher_users.count.positive?
attachment[:fields] << {
title: I18n.t(:field_watcher),
value: Messenger.markup_format(watcher_users.join(', ')),
short: true
}
end
Messenger.speak l(:label_messenger_issue_created,
project_url: Messenger.project_url_markdown(project),
url: send_messenger_mention_url(project, description),
user: author),
channels, url, attachment: attachment, project: project
Messenger.speak l(:label_messenger_issue_created,
project_url: Messenger.project_url_markdown(project),
url: send_messenger_mention_url(project, description),
user: author),
channels, url, attachment: attachment, project: project
ensure
::I18n.locale = initial_language
end
end
def send_messenger_update
@@ -69,9 +76,9 @@ module RedmineMessenger
channels = Messenger.channels_for_project project
url = Messenger.url_for_project project
if Messenger.setting_for_project(project, :messenger_direct_users_messages)
notified_users.each do |user|
channels.append "@#{user.login}" if user.login != current_journal.user.login
if Messenger.setting_for_project project, :messenger_direct_users_messages
messenger_to_be_notified.each do |user|
channels.append "@#{user.login}" unless user == current_journal.user
end
end
@@ -79,35 +86,54 @@ module RedmineMessenger
return if is_private? && !Messenger.setting_for_project(project, :post_private_issues)
return if current_journal.private_notes? && !Messenger.setting_for_project(project, :post_private_notes)
set_language_if_valid Setting.default_language
initial_language = ::I18n.locale
begin
set_language_if_valid Setting.default_language
attachment = {}
if Messenger.setting_for_project(project, :updated_include_description)
attachment_text = Messenger.attachment_text_from_journal current_journal
attachment[:text] = attachment_text if attachment_text.present?
attachment = {}
if Messenger.setting_for_project project, :updated_include_description
attachment_text = Messenger.attachment_text_from_journal current_journal
attachment[:text] = attachment_text if attachment_text.present?
end
fields = current_journal.details.map { |d| Messenger.detail_to_field d, project }
if current_journal.notes.present?
fields << { title: I18n.t(:label_comment),
value: Messenger.markup_format(current_journal.notes),
short: false }
end
fields << { title: I18n.t(:field_is_private), short: true } if current_journal.private_notes?
fields.compact!
attachment[:fields] = fields if fields.any?
Messenger.speak l(:label_messenger_issue_updated,
project_url: Messenger.project_url_markdown(project),
url: send_messenger_mention_url(project, description),
user: current_journal.user),
channels, url, attachment: attachment, project: project
ensure
::I18n.locale = initial_language
end
fields = current_journal.details.map { |d| Messenger.detail_to_field(d, project) }
fields << { title: I18n.t(:field_is_private), short: true } if current_journal.private_notes?
fields.compact!
attachment[:fields] = fields if fields.any?
Messenger.speak l(:label_messenger_issue_updated,
project_url: Messenger.project_url_markdown(project),
url: send_messenger_mention_url(project, description),
user: current_journal.user),
channels, url, attachment: attachment, project: project
end
private
def messenger_to_be_notified
to_be_notified = (notified_users + notified_watchers).compact
to_be_notified.uniq
end
def send_messenger_mention_url(project, text)
mention_to = ''
if Messenger.setting_for_project(project, :auto_mentions) ||
Messenger.textfield_for_project(project, :default_mentions).present?
mention_to = Messenger.mentions project, text
end
"<#{Messenger.object_url self}|#{Messenger.markup_format self}>#{mention_to}"
if current_journal.nil?
"<#{Messenger.object_url self}|#{Messenger.markup_format self}>#{mention_to}"
else
"<#{Messenger.object_url self}#change-#{current_journal.id}|#{Messenger.markup_format self}>#{mention_to}"
end
end
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module RedmineMessenger
module Patches
module PasswordPatch
@@ -15,36 +17,46 @@ module RedmineMessenger
return unless Messenger.setting_for_project project, :post_password
return if is_private?
set_language_if_valid Setting.default_language
channels = Messenger.channels_for_project project
url = Messenger.url_for_project project
return unless channels.present? && url
Messenger.speak l(:label_messenger_password_created,
project_url: Messenger.project_url_markdown(project),
url: Messenger.url_markdown(self, name),
user: User.current),
channels, url, project: project
initial_language = ::I18n.locale
begin
set_language_if_valid Setting.default_language
Messenger.speak l(:label_messenger_password_created,
project_url: Messenger.project_url_markdown(project),
url: Messenger.url_markdown(self, name),
user: User.current),
channels, url, project: project
ensure
::I18n.locale = initial_language
end
end
def send_messenger_update
return unless Messenger.setting_for_project project, :post_password_updates
return if is_private?
set_language_if_valid Setting.default_language
channels = Messenger.channels_for_project project
url = Messenger.url_for_project project
return unless channels.present? && url
Messenger.speak l(:label_messenger_password_updated,
project_url: Messenger.project_url_markdown(project),
url: Messenger.url_markdown(self, name),
user: User.current),
channels, url, project: project
initial_language = ::I18n.locale
begin
set_language_if_valid Setting.default_language
Messenger.speak l(:label_messenger_password_updated,
project_url: Messenger.project_url_markdown(project),
url: Messenger.url_markdown(self, name),
user: User.current),
channels, url, project: project
ensure
::I18n.locale = initial_language
end
end
end
end

View File

@@ -0,0 +1,13 @@
# frozen_string_literal: true
module RedmineMessenger
module Patches
module ProjectPatch
extend ActiveSupport::Concern
included do
has_one :messenger_setting, dependent: :destroy
end
end
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module RedmineMessenger
module Patches
module WikiPagePatch
@@ -14,41 +16,51 @@ module RedmineMessenger
def send_messenger_create
return unless Messenger.setting_for_project project, :post_wiki
set_language_if_valid Setting.default_language
channels = Messenger.channels_for_project project
url = Messenger.url_for_project project
return unless channels.present? && url
Messenger.speak l(:label_messenger_wiki_created,
project_url: Messenger.project_url_markdown(project),
url: Messenger.url_markdown(self, title),
user: User.current),
channels, url, project: project
initial_language = ::I18n.locale
begin
set_language_if_valid Setting.default_language
Messenger.speak l(:label_messenger_wiki_created,
project_url: Messenger.project_url_markdown(project),
url: Messenger.url_markdown(self, title),
user: User.current),
channels, url, project: project
ensure
::I18n.locale = initial_language
end
end
def send_messenger_update
return unless Messenger.setting_for_project project, :post_wiki_updates
set_language_if_valid Setting.default_language
channels = Messenger.channels_for_project project
url = Messenger.url_for_project project
return unless channels.present? && url
attachment = nil
if !content.nil? && content.comments.present?
attachment = {}
attachment[:text] = Messenger.markup_format content.comments.to_s
end
initial_language = ::I18n.locale
begin
set_language_if_valid Setting.default_language
Messenger.speak l(:label_messenger_wiki_updated,
project_url: Messenger.project_url_markdown(project),
url: Messenger.url_markdown(self, title),
user: content.author),
channels, url, project: project, attachment: attachment
attachment = nil
if !content.nil? && content.comments.present?
attachment = {}
attachment[:text] = Messenger.markup_format content.comments.to_s
end
Messenger.speak l(:label_messenger_wiki_updated,
project_url: Messenger.project_url_markdown(project),
url: Messenger.url_markdown(self, title),
user: content.author),
channels, url, project: project, attachment: attachment
ensure
::I18n.locale = initial_language
end
end
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require File.expand_path '../../test_helper', __FILE__
class CommonViewsTest < Redmine::IntegrationTest
@@ -21,14 +23,14 @@ class CommonViewsTest < Redmine::IntegrationTest
end
test 'View user' do
log_user('admin', 'admin')
log_user 'admin', 'admin'
get '/users/2'
assert_response :success
end
test 'View issue' do
log_user('admin', 'admin')
EnabledModule.create(project_id: 1, name: 'issue_tracking')
log_user 'admin', 'admin'
EnabledModule.create project_id: 1, name: 'issue_tracking'
issue = Issue.where(id: 1).first
issue.save
get '/issues/1'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require File.expand_path '../../test_helper', __FILE__
class RoutingTest < Redmine::RoutingTest

View File

@@ -1,3 +0,0 @@
gem 'rubocop', require: false
gem 'rubocop-performance', require: false
gem 'rubocop-rails', require: false

View File

@@ -1,4 +0,0 @@
# for travis debugging
# config.logger = Logger.new(STDOUT)
# config.logger.level = Logger::INFO
# config.log_level = :info

View File

@@ -0,0 +1,6 @@
# = Redmine configuration file
# default configuration options for all environments
default:
sudo_mode: false
sudo_mode_timeout: 1

View File

@@ -1,8 +0,0 @@
test:
adapter: mysql2
database: travis_ci_test
host: localhost
username: root
password:
pool: 5
encoding: utf8mb4

View File

@@ -0,0 +1,8 @@
test:
adapter: mysql2
database: redmine
port: <%= ENV["MYSQL_PORT"] %>
host: 127.0.0.1
username: root
password: BestPasswordEver
encoding: utf8mb4

View File

@@ -0,0 +1,23 @@
production:
adapter: postgresql
host: localhost
database: redmine
username: postgres
password: postgres
encoding: utf8
development:
adapter: postgresql
host: localhost
database: redmine
username: postgres
password: postgres
encoding: utf8
test:
adapter: postgresql
host: localhost
database: redmine
username: postgres
password: postgres
encoding: utf8

View File

@@ -1,8 +0,0 @@
test:
adapter: postgresql
encoding: unicode
pool: 5
database: travis_ci_test
user: postgres

View File

@@ -1,6 +1,6 @@
$VERBOSE = nil
# frozen_string_literal: true
if ENV['JENKINS']
if ENV['COVERAGE']
require 'simplecov'
SimpleCov.start :rails do
add_filter 'init.rb'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require File.expand_path '../../test_helper', __FILE__
class I18nTest < ActiveSupport::TestCase
@@ -18,17 +20,18 @@ class I18nTest < ActiveSupport::TestCase
def test_locales_validness
lang_files_count = Dir[Rails.root.join('plugins/redmine_messenger/config/locales/*.yml')].size
assert_equal lang_files_count, 5
assert_equal 7, lang_files_count
valid_languages.each do |lang|
assert set_language_if_valid(lang)
case lang.to_s
when 'en'
assert_equal 'Messenger username', l(:label_settings_messenger_username)
when 'de', 'fr', 'ja', 'ko', 'pt-BR'
assert_not l(:label_settings_messenger_username) == 'Messenger username', lang
end
end
# check if parse error exists
::I18n.locale = 'de'
assert_equal 'Messenger Benutzer', l(:label_settings_messenger_username)
::I18n.locale = 'en'
assert_equal 'Messenger username', l(:label_settings_messenger_username)
::I18n.locale = 'ja'
assert_equal 'メッセンジャーのユーザー名', l(:label_settings_messenger_username)
set_language_if_valid('en')
set_language_if_valid 'en'
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require File.expand_path '../../test_helper', __FILE__
class IssueTest < ActiveSupport::TestCase
@@ -21,9 +23,9 @@ class IssueTest < ActiveSupport::TestCase
end
def test_create
issue = Issue.new(project_id: 1, tracker_id: 1, author_id: 3, subject: 'test_create')
assert issue.save
issue = Issue.new project_id: 1, tracker_id: 1, author_id: 3, subject: 'test_create'
assert_save issue
assert_equal issue.tracker.default_status, issue.status
assert issue.description.nil?
assert_nil issue.description
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require File.expand_path '../../test_helper', __FILE__
class ProjectTest < ActiveSupport::TestCase
@@ -22,16 +24,16 @@ class ProjectTest < ActiveSupport::TestCase
:workflows
def setup
User.current = User.find(1)
User.current = User.find 1
end
def test_create_project
Project.delete_all
Project.create!(name: 'Project Messenger', identifier: 'project-messenger')
Project.create! name: 'Project Messenger', identifier: 'project-messenger'
assert_equal 1, Project.count
end
def test_load_project
Project.find(1)
Project.find 1
end
end