Compare commits
56 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf8d2d3d4d | ||
|
|
c670b5606d | ||
|
|
8c60b1ae0b | ||
|
|
56fa966d92 | ||
|
|
b658906ee6 | ||
|
|
7fd5910d50 | ||
|
|
712fbcd69a | ||
|
|
1d7e53fd9c | ||
|
|
23673170b4 | ||
|
|
2a73c105e6 | ||
|
|
da9102c741 | ||
|
|
8067fd40e8 | ||
|
|
d3e3bbde0f | ||
|
|
58b4a890ca | ||
|
|
94212d2f3d | ||
|
|
c1b8c033d4 | ||
|
|
c7f97afc0c | ||
|
|
4f5868cc57 | ||
|
|
f670a44c66 | ||
|
|
b2780bf618 | ||
|
|
ca62927d19 | ||
|
|
ba65df0ece | ||
|
|
06d1edd5cc | ||
|
|
0c4482b3a5 | ||
|
|
504730e337 | ||
|
|
c0b892e983 | ||
|
|
9454e06766 | ||
|
|
9339ad53b2 | ||
|
|
bb1920f1ce | ||
|
|
ddf87dd2dc | ||
|
|
41a510fbb4 | ||
|
|
91977c8b83 | ||
|
|
4392789a1b | ||
|
|
466c676e40 | ||
|
|
aecc9572c2 | ||
|
|
6ba0ea782a | ||
|
|
183f8dfa00 | ||
|
|
2cdd0c0cce | ||
|
|
0b91d86290 | ||
|
|
0dc906e61d | ||
|
|
835174d831 | ||
|
|
25744d4337 | ||
|
|
585d49bdec | ||
|
|
b1a527fc52 | ||
|
|
f44366bd75 | ||
|
|
7339e9e382 | ||
|
|
4d447f75ab | ||
|
|
593d7055e0 | ||
|
|
c16dec39e4 | ||
|
|
0ee9fa36e6 | ||
|
|
95a914f1ae | ||
|
|
d683f08eef | ||
|
|
1085b042e5 | ||
|
|
454437cbf5 | ||
|
|
a53fd43ef4 | ||
|
|
7a3d335065 |
17
.eslintrc.yml
Normal file
17
.eslintrc.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
env:
|
||||
browser: true
|
||||
jquery: true
|
||||
extends: 'eslint:recommended'
|
||||
rules:
|
||||
indent:
|
||||
- error
|
||||
- 2
|
||||
linebreak-style:
|
||||
- error
|
||||
- unix
|
||||
quotes:
|
||||
- error
|
||||
- single
|
||||
semi:
|
||||
- error
|
||||
- always
|
||||
64
.rubocop.yml
64
.rubocop.yml
@@ -1,43 +1,57 @@
|
||||
require: rubocop-performance
|
||||
|
||||
Rails:
|
||||
Enabled: true
|
||||
|
||||
Rails/ApplicationRecord:
|
||||
Enabled: false
|
||||
|
||||
AllCops:
|
||||
TargetRubyVersion: 2.1
|
||||
TargetRubyVersion: 2.3
|
||||
TargetRailsVersion: 5.2
|
||||
|
||||
Metrics/AbcSize:
|
||||
Max: 65
|
||||
|
||||
Metrics/BlockLength:
|
||||
Max: 60
|
||||
|
||||
Metrics/ClassLength:
|
||||
Max: 500
|
||||
|
||||
Metrics/CyclomaticComplexity:
|
||||
Max: 20
|
||||
|
||||
Metrics/LineLength:
|
||||
Max: 140
|
||||
|
||||
# Offense count: 34
|
||||
# Configuration parameters: CountComments.
|
||||
Metrics/MethodLength:
|
||||
Max: 60
|
||||
|
||||
# Offense count: 11
|
||||
Metrics/CyclomaticComplexity:
|
||||
Max: 13
|
||||
|
||||
# Offense count: 10
|
||||
Metrics/PerceivedComplexity:
|
||||
Max: 14
|
||||
|
||||
# Offense count: 15
|
||||
Metrics/AbcSize:
|
||||
Max: 65
|
||||
|
||||
Metrics/ModuleLength:
|
||||
Max: 300
|
||||
Max: 500
|
||||
|
||||
Metrics/ClassLength:
|
||||
Max: 300
|
||||
Metrics/PerceivedComplexity:
|
||||
Max: 25
|
||||
|
||||
Rails/SkipsModelValidations:
|
||||
Enabled: false
|
||||
|
||||
Rails/CreateTableWithTimestamps:
|
||||
Enabled: false
|
||||
|
||||
# we drop this, if we drop Rails 4.2 support
|
||||
Rails/ApplicationRecord:
|
||||
Enabled: false
|
||||
|
||||
Performance/ChainArrayAllocation:
|
||||
Enabled: true
|
||||
|
||||
Style/AutoResourceCleanup:
|
||||
Enabled: true
|
||||
|
||||
Style/FrozenStringLiteralComment:
|
||||
Enabled: false
|
||||
|
||||
Style/Documentation:
|
||||
Enabled: false
|
||||
|
||||
Rails/HttpPositionalArguments:
|
||||
Style/ExpandPathArguments:
|
||||
Enabled: false
|
||||
|
||||
Metrics/BlockLength:
|
||||
Max: 50
|
||||
|
||||
3
.slim-lint.yml
Normal file
3
.slim-lint.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
linters:
|
||||
LineLength:
|
||||
max: 140
|
||||
163
.stylelintrc.json
Normal file
163
.stylelintrc.json
Normal file
@@ -0,0 +1,163 @@
|
||||
{
|
||||
"rules": {
|
||||
"at-rule-no-unknown": true,
|
||||
"block-no-empty": true,
|
||||
"color-no-invalid-hex": true,
|
||||
"comment-no-empty": true,
|
||||
"declaration-block-no-duplicate-properties": [
|
||||
true,
|
||||
{
|
||||
"ignore": [
|
||||
"consecutive-duplicates-with-different-values"
|
||||
]
|
||||
}
|
||||
],
|
||||
"declaration-block-no-redundant-longhand-properties": true,
|
||||
"declaration-block-no-shorthand-property-overrides": true,
|
||||
"font-family-no-duplicate-names": true,
|
||||
"font-family-no-missing-generic-family-keyword": true,
|
||||
"function-calc-no-unspaced-operator": true,
|
||||
"function-linear-gradient-no-nonstandard-direction": true,
|
||||
"keyframe-declaration-no-important": true,
|
||||
"media-feature-name-no-unknown": true,
|
||||
"no-descending-specificity": true,
|
||||
"no-duplicate-at-import-rules": true,
|
||||
"no-duplicate-selectors": true,
|
||||
"no-empty-source": true,
|
||||
"no-extra-semicolons": true,
|
||||
"no-invalid-double-slash-comments": true,
|
||||
"property-no-unknown": true,
|
||||
"selector-pseudo-class-no-unknown": true,
|
||||
"selector-pseudo-element-no-unknown": true,
|
||||
"selector-type-no-unknown": true,
|
||||
"string-no-newline": true,
|
||||
"unit-no-unknown": true,
|
||||
"at-rule-empty-line-before": [
|
||||
"always",
|
||||
{
|
||||
"except": [
|
||||
"blockless-after-same-name-blockless",
|
||||
"first-nested"
|
||||
],
|
||||
"ignore": [
|
||||
"after-comment"
|
||||
]
|
||||
}
|
||||
],
|
||||
"at-rule-name-case": "lower",
|
||||
"at-rule-name-space-after": "always-single-line",
|
||||
"at-rule-semicolon-newline-after": "always",
|
||||
"block-closing-brace-empty-line-before": "never",
|
||||
"block-closing-brace-newline-after": "always",
|
||||
"block-closing-brace-newline-before": "always-multi-line",
|
||||
"block-closing-brace-space-before": "always-single-line",
|
||||
"block-opening-brace-newline-after": "always-multi-line",
|
||||
"block-opening-brace-space-after": "always-single-line",
|
||||
"block-opening-brace-space-before": "always",
|
||||
"color-hex-case": "lower",
|
||||
"color-hex-length": "short",
|
||||
"comment-empty-line-before": [
|
||||
"always",
|
||||
{
|
||||
"except": [
|
||||
"first-nested"
|
||||
],
|
||||
"ignore": [
|
||||
"stylelint-commands"
|
||||
]
|
||||
}
|
||||
],
|
||||
"comment-whitespace-inside": "always",
|
||||
"custom-property-empty-line-before": [
|
||||
"always",
|
||||
{
|
||||
"except": [
|
||||
"after-custom-property",
|
||||
"first-nested"
|
||||
],
|
||||
"ignore": [
|
||||
"after-comment",
|
||||
"inside-single-line-block"
|
||||
]
|
||||
}
|
||||
],
|
||||
"declaration-bang-space-after": "never",
|
||||
"declaration-bang-space-before": "always",
|
||||
"declaration-block-semicolon-newline-after": "always-multi-line",
|
||||
"declaration-block-semicolon-space-after": "always-single-line",
|
||||
"declaration-block-semicolon-space-before": "never",
|
||||
"declaration-block-single-line-max-declarations": 1,
|
||||
"declaration-block-trailing-semicolon": "always",
|
||||
"declaration-colon-newline-after": "always-multi-line",
|
||||
"declaration-colon-space-after": "always-single-line",
|
||||
"declaration-colon-space-before": "never",
|
||||
"declaration-empty-line-before": [
|
||||
"always",
|
||||
{
|
||||
"except": [
|
||||
"after-declaration",
|
||||
"first-nested"
|
||||
],
|
||||
"ignore": [
|
||||
"after-comment",
|
||||
"inside-single-line-block"
|
||||
]
|
||||
}
|
||||
],
|
||||
"function-comma-newline-after": "always-multi-line",
|
||||
"function-comma-space-after": "always-single-line",
|
||||
"function-comma-space-before": "never",
|
||||
"function-max-empty-lines": 0,
|
||||
"function-name-case": "lower",
|
||||
"function-parentheses-newline-inside": "always-multi-line",
|
||||
"function-parentheses-space-inside": "never-single-line",
|
||||
"function-whitespace-after": "always",
|
||||
"indentation": 2,
|
||||
"length-zero-no-unit": true,
|
||||
"max-empty-lines": 1,
|
||||
"media-feature-colon-space-after": "always",
|
||||
"media-feature-colon-space-before": "never",
|
||||
"media-feature-name-case": "lower",
|
||||
"media-feature-parentheses-space-inside": "never",
|
||||
"media-feature-range-operator-space-after": "always",
|
||||
"media-feature-range-operator-space-before": "always",
|
||||
"media-query-list-comma-newline-after": "always-multi-line",
|
||||
"media-query-list-comma-space-after": "always-single-line",
|
||||
"media-query-list-comma-space-before": "never",
|
||||
"no-eol-whitespace": true,
|
||||
"no-missing-end-of-source-newline": true,
|
||||
"number-leading-zero": "always",
|
||||
"number-no-trailing-zeros": true,
|
||||
"property-case": "lower",
|
||||
"rule-empty-line-before": [
|
||||
"always-multi-line",
|
||||
{
|
||||
"except": [
|
||||
"first-nested"
|
||||
],
|
||||
"ignore": [
|
||||
"after-comment"
|
||||
]
|
||||
}
|
||||
],
|
||||
"selector-attribute-brackets-space-inside": "never",
|
||||
"selector-attribute-operator-space-after": "never",
|
||||
"selector-attribute-operator-space-before": "never",
|
||||
"selector-combinator-space-after": "always",
|
||||
"selector-combinator-space-before": "always",
|
||||
"selector-descendant-combinator-no-non-space": true,
|
||||
"selector-list-comma-newline-after": "always",
|
||||
"selector-list-comma-space-before": "never",
|
||||
"selector-max-empty-lines": 0,
|
||||
"selector-pseudo-class-case": "lower",
|
||||
"selector-pseudo-class-parentheses-space-inside": "never",
|
||||
"selector-pseudo-element-case": "lower",
|
||||
"selector-pseudo-element-colon-notation": "double",
|
||||
"selector-type-case": "lower",
|
||||
"unit-case": "lower",
|
||||
"value-list-comma-newline-after": "always-multi-line",
|
||||
"value-list-comma-space-after": "always-single-line",
|
||||
"value-list-comma-space-before": "never",
|
||||
"value-list-max-empty-lines": 0
|
||||
}
|
||||
}
|
||||
49
.travis.yml
Normal file
49
.travis.yml
Normal file
@@ -0,0 +1,49 @@
|
||||
language: ruby
|
||||
|
||||
rvm:
|
||||
- 2.5.3
|
||||
- 2.4.5
|
||||
- 2.3.8
|
||||
|
||||
env:
|
||||
- REDMINE_VER=4.0-stable DB=postgresql
|
||||
- REDMINE_VER=3.4-stable DB=postgresql
|
||||
|
||||
sudo: true
|
||||
|
||||
addons:
|
||||
postgresql: "9.6"
|
||||
|
||||
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
|
||||
- git clone $REDMINE_GIT_REPO $REDMINE_PATH
|
||||
- cd $REDMINE_PATH
|
||||
- if [[ "$REDMINE_VER" != "master" ]]; then git checkout -b $REDMINE_VER origin/$REDMINE_VER; 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 redmine:load_default_data REDMINE_LANG=en
|
||||
# - bundle exec rake db:structure:dump
|
||||
- psql -c 'create database travis_ci_test;' -U postgres
|
||||
# - bundle exec rake db:create
|
||||
- bundle exec rake db:migrate
|
||||
- bundle exec rake redmine:plugins:migrate
|
||||
|
||||
script:
|
||||
- export SKIP_COVERAGE=1
|
||||
- if [[ "$REDMINE_VER" == "master" ]]; then bundle exec rake redmine:plugins:test:units NAME=$PLUGIN_NAME; fi
|
||||
- if [[ "$REDMINE_VER" == "master" ]]; then bundle exec rake redmine:plugins:test:functionals NAME=$PLUGIN_NAME; fi
|
||||
- if [[ "$REDMINE_VER" == "master" ]]; then bundle exec rake redmine:plugins:test:integration NAME=$PLUGIN_NAME; fi
|
||||
- if [[ "$REDMINE_VER" != "master" ]]; then bundle exec rake redmine:plugins:test NAME=$PLUGIN_NAME RUBYOPT="-W0"; fi
|
||||
79
CHANGELOG.md
79
CHANGELOG.md
@@ -1,46 +1,79 @@
|
||||
Changelog
|
||||
=========
|
||||
|
||||
## 1.0.1
|
||||
1.0.5
|
||||
-----
|
||||
|
||||
* Japanese translation has been added - thanks @Yoto
|
||||
* Default mentions has been added - thanks @xstasi
|
||||
- ruby 2.3.x or newer is required
|
||||
|
||||
## 1.0.0
|
||||
|
||||
* Redmine 3.4.x compatibility
|
||||
* Commit message issue bug fix
|
||||
* Some code cleanups
|
||||
1.0.4
|
||||
-----
|
||||
|
||||
## 0.9.9
|
||||
- Frensh translation added - thanks to @ZerooCool
|
||||
|
||||
* All global messenger settings can be overwritten project based
|
||||
* Locale support added
|
||||
* Wiki added supported for notification
|
||||
* Contact added/updated supported for notification (if redmine_contacts is installed)
|
||||
* Password added/updated supported for notification (if redmine_passwords is installed)
|
||||
* DB entry added/updated supported for notification (if redmine_db is installed)
|
||||
* SSL verify can be disabled
|
||||
* Lots of refactoring and code cleanups
|
||||
* Swith from httpclient to net/http
|
||||
* Fork of redmine_rocketchat, redmine_slack and redmine_mattermost (base functions for all three messenger)
|
||||
1.0.3
|
||||
-----
|
||||
|
||||
## v0.6.1
|
||||
- Redmine 4 support
|
||||
|
||||
|
||||
1.0.2
|
||||
-----
|
||||
|
||||
- Bug fixed with issue urls, if Redmine is in subdirectory
|
||||
- slim is used as template engine
|
||||
- add private contacts, db and passwords support (if plugins are installed)
|
||||
- Discord support added to documentation
|
||||
|
||||
1.0.1
|
||||
-----
|
||||
|
||||
- Japanese translation has been added - thanks @Yoto
|
||||
- Default mentions has been added - thanks @xstasi
|
||||
|
||||
1.0.0
|
||||
-----
|
||||
|
||||
- Redmine 3.4.x compatibility
|
||||
- Commit message issue bug fix
|
||||
- Some code cleanups
|
||||
|
||||
0.9.9
|
||||
-----
|
||||
|
||||
- All global messenger settings can be overwritten project based
|
||||
- Locale support added
|
||||
- Wiki added supported for notification
|
||||
- Contact added/updated supported for notification (if redmine_contacts is installed)
|
||||
- Password added/updated supported for notification (if redmine_passwords is installed)
|
||||
- DB entry added/updated supported for notification (if redmine_db is installed)
|
||||
- SSL verify can be disabled
|
||||
- Lots of refactoring and code cleanups
|
||||
- Swith from httpclient to net/http
|
||||
- Fork of redmine_rocketchat, redmine_slack and redmine_mattermost (base functions for all three messenger)
|
||||
|
||||
v0.6.1
|
||||
------
|
||||
|
||||
unknown changes
|
||||
|
||||
## v0.4
|
||||
v0.4
|
||||
----
|
||||
|
||||
unknown changes
|
||||
|
||||
## v0.3
|
||||
v0.3
|
||||
----
|
||||
|
||||
unknown changes
|
||||
|
||||
## v0.2
|
||||
v0.2
|
||||
----
|
||||
|
||||
unknown changes
|
||||
|
||||
## v0.1
|
||||
v0.1
|
||||
----
|
||||
|
||||
unknown changes
|
||||
|
||||
7
Gemfile
Normal file
7
Gemfile
Normal file
@@ -0,0 +1,7 @@
|
||||
gem 'slim-rails'
|
||||
gem 'validate_url'
|
||||
|
||||
group :test do
|
||||
gem 'rubocop', require: false
|
||||
gem 'rubocop-performance', require: false
|
||||
end
|
||||
36
README.md
36
README.md
@@ -1,10 +1,12 @@
|
||||
# Messenger plugin for Redmine
|
||||
Messenger plugin for Redmine
|
||||
============================
|
||||
|
||||
This plugin posts updates to issues in your Redmine installation to [Slack](https://slack.com/), [Rocket.Chat](https://rocket.chat/) or [Mattermost](https://about.mattermost.com/) channel.
|
||||
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.
|
||||
|
||||
[](https://gemnasium.com/github.com/AlphaNodes/redmine_messenger) 
|
||||
[](https://www.redmine.org/plugins/redmine_messenger) [](https://travis-ci.org/AlphaNodes/redmine_messenger)
|
||||
|
||||
## Features
|
||||
Features
|
||||
--------
|
||||
|
||||
* Post information to messenger channel
|
||||
* post issue updates
|
||||
@@ -19,7 +21,8 @@ This plugin posts updates to issues in your Redmine installation to [Slack](http
|
||||
* parent project support (inherit messenger settings from parent project)
|
||||
* multiple channel support (define one or more channels to deliver note)
|
||||
|
||||
## Screenshot
|
||||
Screenshot
|
||||
----------
|
||||
|
||||
Mattermost output:
|
||||
|
||||
@@ -29,7 +32,8 @@ Redmine configuration:
|
||||
|
||||

|
||||
|
||||
## Prepare your messenger service
|
||||
Prepare your messenger service
|
||||
------------------------------
|
||||
|
||||
### Slack
|
||||
|
||||
@@ -39,23 +43,31 @@ Go to Slack documentation [Incoming Webhooks](https://api.slack.com/incoming-web
|
||||
|
||||
Go to Mattermost documentation [Incoming Webhooks](https://docs.mattermost.com/developer/webhooks-incoming.html) for more information to set up Incoming WebHook
|
||||
|
||||
### Discord
|
||||
|
||||
Go to Discord documentation [Intro to Webhooks ](https://support.discordapp.com/hc/en-us/articles/228383668) for more information to set up Incoming WebHook
|
||||
You have to add /slack after your webhook url.
|
||||
|
||||
### Rocket.Chat
|
||||
|
||||
Go to Rocket.Chat documentation [Incoming WebHook Scripting](https://rocket.chat/docs/administrator-guides/integrations/) for more information to set up Incoming WebHook
|
||||
|
||||
|
||||
## Requirements
|
||||
Requirements
|
||||
------------
|
||||
|
||||
* Redmine version >= 3.0.0
|
||||
* Ruby version >= 2.1.5
|
||||
* Ruby version >= 2.3.0
|
||||
|
||||
|
||||
## Installation
|
||||
Installation
|
||||
------------
|
||||
|
||||
Install ``redmine_messenger`` plugin for `Redmine`
|
||||
|
||||
cd $REDMINE_ROOT
|
||||
git clone git://github.com/alphanodes/redmine_messenger.git plugins/redmine_messenger
|
||||
bundle install --without development test
|
||||
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
|
||||
|
||||
Restart Redmine (application server) and you should see the plugin show up in the Plugins page.
|
||||
@@ -66,7 +78,8 @@ visible to users, you can find each channel's handle by navigating inside the ch
|
||||
and clicking the down-arrow and selecting view info).
|
||||
|
||||
|
||||
## Uninstall
|
||||
Uninstall
|
||||
---------
|
||||
|
||||
Uninstall ``redmine_messenger``
|
||||
|
||||
@@ -77,7 +90,8 @@ Uninstall ``redmine_messenger``
|
||||
Restart Redmine (application server)
|
||||
|
||||
|
||||
## Credits
|
||||
Credits
|
||||
-------
|
||||
|
||||
The source code is forked from
|
||||
|
||||
|
||||
@@ -1,35 +1,46 @@
|
||||
# Redmine Messenger plugin for Redmine
|
||||
|
||||
class MessengerSettingsController < ApplicationController
|
||||
layout 'base'
|
||||
before_action :find_project_by_project_id
|
||||
before_action :authorize
|
||||
|
||||
before_action :find_project, :authorize, :find_user
|
||||
|
||||
def save
|
||||
setting = MessengerSetting.find_or_create @project.id
|
||||
begin
|
||||
setting.transaction do
|
||||
# setting.auto_preview_enabled = auto_preview_enabled
|
||||
setting.assign_attributes(params[:setting])
|
||||
setting.save!
|
||||
end
|
||||
def update
|
||||
setting = MessengerSetting.find_or_create(@project.id)
|
||||
if setting.update(allowed_params)
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
rescue => e
|
||||
flash[:error] = 'Updating failed.' + e.message
|
||||
redirect_to settings_project_path(@project, tab: 'messenger')
|
||||
else
|
||||
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) }
|
||||
end
|
||||
end
|
||||
|
||||
redirect_to controller: 'projects', action: 'settings', id: @project, tab: 'messenger'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_project
|
||||
@project = Project.find(params[:id])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def find_user
|
||||
@user = User.current
|
||||
def allowed_params
|
||||
params.require(:setting).permit :messenger_url,
|
||||
:messenger_icon,
|
||||
:messenger_channel,
|
||||
:messenger_username,
|
||||
:messenger_verify_ssl,
|
||||
:auto_mentions,
|
||||
:default_mentions,
|
||||
:display_watchers,
|
||||
:post_updates,
|
||||
:new_include_description,
|
||||
:updated_include_description,
|
||||
:post_private_issues,
|
||||
:post_private_notes,
|
||||
:post_wiki,
|
||||
:post_wiki_updates,
|
||||
:post_db,
|
||||
:post_db_updates,
|
||||
:post_private_db,
|
||||
:post_contact,
|
||||
:post_contact_updates,
|
||||
:post_private_contacts,
|
||||
:post_password,
|
||||
:post_password_updates
|
||||
end
|
||||
end
|
||||
|
||||
14
app/helpers/messenger_projects_helper.rb
Normal file
14
app/helpers/messenger_projects_helper.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
module MessengerProjectsHelper
|
||||
def project_settings_tabs
|
||||
tabs = super
|
||||
|
||||
if User.current.allowed_to?(:manage_messenger, @project)
|
||||
tabs << { name: 'messenger',
|
||||
action: :show,
|
||||
partial: 'messenger_settings/show',
|
||||
label: :label_messenger }
|
||||
end
|
||||
|
||||
tabs
|
||||
end
|
||||
end
|
||||
@@ -1,9 +1,21 @@
|
||||
# Redmine Messenger plugin for Redmine
|
||||
require 'net/http'
|
||||
|
||||
class Messenger
|
||||
include Redmine::I18n
|
||||
|
||||
def self.markup_format(text)
|
||||
# TODO: output format should be markdown, but at the moment there is no
|
||||
# solution without using pandoc (http://pandoc.org/), which requires
|
||||
# packages on os level
|
||||
#
|
||||
# Redmine::WikiFormatting.html_parser.to_text(text)
|
||||
ERB::Util.html_escape(text)
|
||||
end
|
||||
|
||||
def self.default_url_options
|
||||
{ only_path: true, script_name: Redmine::Utils.relative_url_root }
|
||||
end
|
||||
|
||||
def self.speak(msg, channels, url, options)
|
||||
url ||= RedmineMessenger.settings[:messenger_url]
|
||||
|
||||
@@ -17,7 +29,7 @@ class Messenger
|
||||
|
||||
username = Messenger.textfield_for_project(options[:project], :messenger_username)
|
||||
params[:username] = username if username.present?
|
||||
params[:attachments] = [options[:attachment]] if options[:attachment] && options[:attachment].any?
|
||||
params[:attachments] = [options[:attachment]] if options[:attachment]&.any?
|
||||
|
||||
icon = Messenger.textfield_for_project(options[:project], :messenger_icon)
|
||||
if icon.present?
|
||||
@@ -32,18 +44,14 @@ class Messenger
|
||||
uri = URI(url)
|
||||
params[:channel] = channel
|
||||
http_options = { use_ssl: uri.scheme == 'https' }
|
||||
unless RedmineMessenger.setting?(:messenger_verify_ssl)
|
||||
http_options[:verify_mode] = OpenSSL::SSL::VERIFY_NONE
|
||||
end
|
||||
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)
|
||||
unless [Net::HTTPSuccess, Net::HTTPRedirection, Net::HTTPOK].include? response
|
||||
Rails.logger.warn(response)
|
||||
end
|
||||
Rails.logger.warn(response) unless [Net::HTTPSuccess, Net::HTTPRedirection, Net::HTTPOK].include? response
|
||||
end
|
||||
rescue StandardError => e
|
||||
Rails.logger.warn("cannot connect to #{url}")
|
||||
@@ -53,34 +61,39 @@ class Messenger
|
||||
end
|
||||
|
||||
def self.object_url(obj)
|
||||
if Setting.host_name.to_s =~ %r{/\A(https?\:\/\/)?(.+?)(\:(\d+))?(\/.+)?\z/i}
|
||||
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)
|
||||
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))
|
||||
Rails.application.routes.url_for(obj.event_url(host: Setting.host_name, protocol: Setting.protocol, script_name: ''))
|
||||
end
|
||||
end
|
||||
|
||||
def self.url_for_project(proj)
|
||||
return if proj.blank?
|
||||
|
||||
# project based
|
||||
pm = MessengerSetting.find_by(project_id: proj.id)
|
||||
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?
|
||||
|
||||
nil
|
||||
end
|
||||
|
||||
def self.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?
|
||||
|
||||
default_textfield(proj, config)
|
||||
end
|
||||
|
||||
@@ -88,19 +101,20 @@ class Messenger
|
||||
# parent project based
|
||||
parent_field = textfield_for_project(proj.parent, config)
|
||||
return parent_field if parent_field.present?
|
||||
if RedmineMessenger.settings[config].present?
|
||||
return RedmineMessenger.settings[config]
|
||||
end
|
||||
return RedmineMessenger.settings[config] if RedmineMessenger.settings[config].present?
|
||||
|
||||
''
|
||||
end
|
||||
|
||||
def self.channels_for_project(proj)
|
||||
return [] if proj.blank?
|
||||
|
||||
# project based
|
||||
pm = MessengerSetting.find_by(project_id: proj.id)
|
||||
if !pm.nil? && pm.messenger_channel.present?
|
||||
return [] if pm.messenger_channel == '-'
|
||||
return pm.messenger_channel.split(',').map(&:strip).uniq
|
||||
|
||||
return pm.messenger_channel.split(',').map!(&:strip).uniq
|
||||
end
|
||||
default_project_channels(proj)
|
||||
end
|
||||
@@ -112,13 +126,15 @@ class Messenger
|
||||
# system based
|
||||
if RedmineMessenger.settings[:messenger_channel].present? &&
|
||||
RedmineMessenger.settings[:messenger_channel] != '-'
|
||||
return RedmineMessenger.settings[:messenger_channel].split(',').map(&:strip).uniq
|
||||
return RedmineMessenger.settings[:messenger_channel].split(',').map!(&:strip).uniq
|
||||
end
|
||||
|
||||
[]
|
||||
end
|
||||
|
||||
def self.setting_for_project(proj, config)
|
||||
return false if proj.blank?
|
||||
|
||||
@setting_found = 0
|
||||
# project based
|
||||
pm = MessengerSetting.find_by(project_id: proj.id)
|
||||
@@ -138,6 +154,7 @@ class Messenger
|
||||
end
|
||||
# system based
|
||||
return true if RedmineMessenger.settings[config].present? && RedmineMessenger.setting?(config)
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
|
||||
@@ -1,54 +1,7 @@
|
||||
# Redmine Messenger plugin for Redmine
|
||||
|
||||
class MessengerSetting < ActiveRecord::Base
|
||||
include Redmine::SafeAttributes
|
||||
belongs_to :project
|
||||
|
||||
validates :project_id, presence: true
|
||||
|
||||
safe_attributes 'messenger_url',
|
||||
'messenger_icon',
|
||||
'messenger_channel',
|
||||
'messenger_username',
|
||||
'messenger_verify_ssl',
|
||||
'auto_mentions',
|
||||
'default_mentions',
|
||||
'display_watchers',
|
||||
'post_updates',
|
||||
'new_include_description',
|
||||
'updated_include_description',
|
||||
'post_private_issues',
|
||||
'post_private_notes',
|
||||
'post_wiki',
|
||||
'post_wiki_updates',
|
||||
'post_db',
|
||||
'post_db_updates',
|
||||
'post_contact',
|
||||
'post_contact_updates',
|
||||
'post_password',
|
||||
'post_password_updates'
|
||||
|
||||
attr_accessible :messenger_url,
|
||||
:messenger_icon,
|
||||
:messenger_channel,
|
||||
:messenger_username,
|
||||
:messenger_verify_ssl,
|
||||
:auto_mentions,
|
||||
:default_mentions,
|
||||
:display_watchers,
|
||||
:post_updates,
|
||||
:new_include_description,
|
||||
:updated_include_description,
|
||||
:post_private_issues,
|
||||
:post_private_notes,
|
||||
:post_wiki,
|
||||
:post_wiki_updates,
|
||||
:post_db,
|
||||
:post_db_updates,
|
||||
:post_contact,
|
||||
:post_contact_updates,
|
||||
:post_password,
|
||||
:post_password_updates
|
||||
validates :messenger_url, url: { allow_blank: true, message: l(:error_messenger_invalid_url) }
|
||||
|
||||
def self.find_or_create(p_id)
|
||||
setting = MessengerSetting.find_by(project_id: p_id)
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
<p>
|
||||
<%= f.select mf, project_messenger_options(@messenger_setting.send(mf)), label: l("label_settings_#{mf}") %>
|
||||
<em class="info" style="display: inline;"><%= l(:label_default) %>: <%= project_setting_messenger_default_value(mf) %></em>
|
||||
</p>
|
||||
7
app/views/messenger_settings/_messenger_select.html.slim
Normal file
7
app/views/messenger_settings/_messenger_select.html.slim
Normal file
@@ -0,0 +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)
|
||||
' :
|
||||
= project_setting_messenger_default_value(mf)
|
||||
@@ -1,4 +0,0 @@
|
||||
<p>
|
||||
<%= f.text_field mf, size: size, label: l("label_settings_#{mf}") %>
|
||||
<em class="info"><%= l(:label_messenger_project_text_field_info) %> (<%= l(:label_default) %>: <%= Messenger.default_textfield(@project, mf) %>)</em>
|
||||
</p>
|
||||
9
app/views/messenger_settings/_messenger_text.html.slim
Normal file
9
app/views/messenger_settings/_messenger_text.html.slim
Normal file
@@ -0,0 +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_default)
|
||||
' :
|
||||
= Messenger.default_textfield(@project, mf)
|
||||
| )
|
||||
@@ -1,75 +0,0 @@
|
||||
|
||||
<div class="box tabular messenger_settings">
|
||||
<%
|
||||
@messenger_setting = MessengerSetting.find_or_create(@project.id)
|
||||
%>
|
||||
|
||||
<%= labelled_form_for :setting, @messenger_setting,
|
||||
url: { controller: 'messenger_settings',
|
||||
action: 'save', id: @project, tab: 'messenger',
|
||||
partial: 'messenger_settings/save',
|
||||
setting_id: @messenger_setting.id } do |f| %>
|
||||
<%= error_messages_for 'messenger_setting' %>
|
||||
<div class="box">
|
||||
|
||||
<div class="info"><%= t(:messenger_settings_project_intro) %></div><br />
|
||||
|
||||
<p><%= f.text_field :messenger_url, size: 60, label: l(:label_settings_messenger_url) %><em class="info"><%= l(:label_messenger_project_text_field_info) %> (<%= l(:label_messenger_default_not_visible) %>)</em></p>
|
||||
|
||||
<%= 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 } %>
|
||||
|
||||
<br />
|
||||
<h3><%= l(:label_issue_plural) %></h3>
|
||||
|
||||
<div class="info"><%= t(:messenger_issue_intro) %></div><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 } %>
|
||||
|
||||
<br />
|
||||
<h3><%= l(:label_wiki) %></h3>
|
||||
|
||||
<div class="info"><%= t(:messenger_wiki_intro) %></div><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 } %>
|
||||
|
||||
<% if RedmineMessenger::REDMINE_DB_SUPPORT && User.current.allowed_to?(:view_db_entries, @project) %>
|
||||
<br />
|
||||
<h3><%= l(:label_db_entry_plural) %></h3>
|
||||
<div class="info"><%= t(:messenger_db_intro) %></div><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 } %>
|
||||
<% end %>
|
||||
|
||||
<% if RedmineMessenger::REDMINE_CONTACTS_SUPPORT && User.current.allowed_to?(:view_contacts, @project) %>
|
||||
<br />
|
||||
<h3><%= l(:label_contact_plural) %></h3>
|
||||
<div class="info"><%= t(:messenger_contacts_intro) %></div><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 } %>
|
||||
<% end %>
|
||||
|
||||
<% if Redmine::Plugin.installed?('redmine_passwords') && User.current.allowed_to?(:view_passwords, @project) %>
|
||||
<br />
|
||||
<h3><%= l(:label_settings_post_password) %></h3>
|
||||
<div class="info"><%= t(:messenger_passwords_intro) %></div><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 } %>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
70
app/views/messenger_settings/_show.html.slim
Normal file
70
app/views/messenger_settings/_show.html.slim
Normal file
@@ -0,0 +1,70 @@
|
||||
.box.tabular.messenger_settings
|
||||
- @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|
|
||||
= error_messages_for 'messenger_setting'
|
||||
.box
|
||||
.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_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 }
|
||||
|
||||
br
|
||||
h3 = 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 }
|
||||
|
||||
br
|
||||
h3 = 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 }
|
||||
|
||||
- if RedmineMessenger::REDMINE_DB_SUPPORT && User.current.allowed_to?(:view_db_entries, @project)
|
||||
br
|
||||
h3 = l(:label_db_entry_plural)
|
||||
.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 }
|
||||
|
||||
- if RedmineMessenger::REDMINE_CONTACTS_SUPPORT && User.current.allowed_to?(:view_contacts, @project)
|
||||
br
|
||||
h3 = 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 }
|
||||
|
||||
- if Redmine::Plugin.installed?('redmine_passwords') && User.current.allowed_to?(:view_passwords, @project)
|
||||
br
|
||||
h3 = l(:label_settings_post_password)
|
||||
.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 }
|
||||
|
||||
= submit_tag l(:button_save)
|
||||
@@ -1,134 +0,0 @@
|
||||
<% @settings = ActionController::Parameters.new(@settings) %>
|
||||
|
||||
<div class="info"><%= t(:messenger_settings_intro) %></div><br />
|
||||
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_settings_messenger_url)) %>
|
||||
<%= text_field_tag('settings[messenger_url]', @settings[:messenger_url], size: 60, placeholder: 'https://rocket.chat/hooks/my_rocket_chat_token') %>
|
||||
<em class="info"><%= t(:messenger_url_info_html) %></em>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_settings_messenger_icon)) %>
|
||||
<%= text_field_tag('settings[messenger_icon]', @settings[:messenger_icon], size: 60) %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_settings_messenger_channel)) %>
|
||||
<%= text_field_tag('settings[messenger_channel]', @settings[:messenger_channel], size: 30, placeholder: 'redmine') %>
|
||||
<em class="info"><%= t(:messenger_channel_info_html) %></em>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_settings_messenger_username)) %>
|
||||
<%= text_field_tag('settings[messenger_username]', @settings[:messenger_username], size: 30) %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_settings_messenger_verify_ssl)) %>
|
||||
<%= check_box_tag 'settings[messenger_verify_ssl]', 1, @settings[:messenger_verify_ssl].to_i == 1 %>
|
||||
<em class="info"><%= t(:messenger_verify_ssl_info_html) %></em>
|
||||
</p>
|
||||
|
||||
<br />
|
||||
<h3><%= l(:label_issue_plural) %></h3>
|
||||
|
||||
<div class="info"><%= t(:messenger_issue_intro) %></div><br />
|
||||
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_settings_auto_mentions)) %>
|
||||
<%= check_box_tag 'settings[auto_mentions]', 1, @settings[:auto_mentions].to_i == 1 %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_settings_default_mentions)) %>
|
||||
<%= text_field_tag('settings[default_mentions]', @settings[:default_mentions], size: 30) %>
|
||||
<em class="info"><%= t(:default_mentionsl_info) %></em>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_settings_display_watchers)) %>
|
||||
<%= check_box_tag 'settings[display_watchers]', 1, @settings[:display_watchers].to_i == 1 %>
|
||||
</p>
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_settings_post_updates)) %>
|
||||
<%= check_box_tag 'settings[post_updates]', 1, @settings[:post_updates].to_i == 1 %>
|
||||
</p>
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_settings_new_include_description)) %>
|
||||
<%= check_box_tag 'settings[new_include_description]', 1, @settings[:new_include_description].to_i == 1 %>
|
||||
</p>
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_settings_updated_include_description)) %>
|
||||
<%= check_box_tag 'settings[updated_include_description]', 1, @settings[:updated_include_description].to_i == 1 %>
|
||||
</p>
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_settings_post_private_issues)) %>
|
||||
<%= check_box_tag 'settings[post_private_issues]', 1, @settings[:post_private_issues].to_i == 1 %>
|
||||
</p>
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_settings_post_private_notes)) %>
|
||||
<%= check_box_tag 'settings[post_private_notes]', 1, @settings[:post_private_notes].to_i == 1 %>
|
||||
</p>
|
||||
|
||||
<br />
|
||||
<h3><%= l(:label_wiki) %></h3>
|
||||
|
||||
<div class="info"><%= t(:messenger_wiki_intro) %></div><br />
|
||||
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_settings_post_wiki)) %>
|
||||
<%= check_box_tag 'settings[post_wiki]', 1, @settings[:post_wiki].to_i == 1 %>
|
||||
</p>
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_settings_post_wiki_updates)) %>
|
||||
<%= check_box_tag 'settings[post_wiki_updates]', 1, @settings[:post_wiki_updates].to_i == 1 %>
|
||||
</p>
|
||||
|
||||
<% if RedmineMessenger::REDMINE_DB_SUPPORT %>
|
||||
<br />
|
||||
<h3><%= l(:label_db_entry_plural) %></h3>
|
||||
|
||||
<div class="info"><%= t(:messenger_db_intro) %></div><br />
|
||||
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_settings_post_db)) %>
|
||||
<%= check_box_tag 'settings[post_db]', 1, @settings[:post_db].to_i == 1 %>
|
||||
</p>
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_settings_post_db_updates)) %>
|
||||
<%= check_box_tag 'settings[post_db_updates]', 1, @settings[:post_db_updates].to_i == 1 %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<% if RedmineMessenger::REDMINE_CONTACTS_SUPPORT %>
|
||||
<br />
|
||||
<h3><%= l(:label_contact_plural) %></h3>
|
||||
|
||||
<div class="info"><%= t(:messenger_contacts_intro) %></div><br />
|
||||
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_settings_post_contact)) %>
|
||||
<%= check_box_tag 'settings[post_contact]', 1, @settings[:post_contact].to_i == 1 %>
|
||||
</p>
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_settings_post_contact_updates)) %>
|
||||
<%= check_box_tag 'settings[post_contact_updates]', 1, @settings[:post_contact_updates].to_i == 1 %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<% if Redmine::Plugin.installed?('redmine_passwords') %>
|
||||
<br />
|
||||
<h3><%= l(:label_password_plural) %></h3>
|
||||
|
||||
<div class="info"><%= t(:messenger_passwords_intro) %></div><br />
|
||||
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_settings_post_password)) %>
|
||||
<%= check_box_tag 'settings[post_password]', 1, @settings[:post_password].to_i == 1 %>
|
||||
</p>
|
||||
<p>
|
||||
<%= content_tag(:label, l(:label_settings_post_password_updates)) %>
|
||||
<%= check_box_tag 'settings[post_password_updates]', 1, @settings[:post_password_updates].to_i == 1 %>
|
||||
</p>
|
||||
<% end %>
|
||||
105
app/views/settings/_messenger_settings.html.slim
Normal file
105
app/views/settings/_messenger_settings.html.slim
Normal file
@@ -0,0 +1,105 @@
|
||||
- @settings = ActionController::Parameters.new(@settings) unless Rails.version >= '5.2'
|
||||
|
||||
.info = t(:messenger_settings_intro)
|
||||
br
|
||||
p
|
||||
= content_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)
|
||||
p
|
||||
= content_tag(:label, l(:label_settings_messenger_icon))
|
||||
= text_field_tag('settings[messenger_icon]', @settings[:messenger_icon], size: 60)
|
||||
p
|
||||
= content_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)
|
||||
p
|
||||
= content_tag(:label, l(:label_settings_messenger_username))
|
||||
= text_field_tag('settings[messenger_username]', @settings[:messenger_username], size: 30)
|
||||
p
|
||||
= content_tag(: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)
|
||||
|
||||
br
|
||||
h3 = l(:label_issue_plural)
|
||||
.info = t(:messenger_issue_intro)
|
||||
br
|
||||
p
|
||||
= content_tag(:label, l(:label_settings_auto_mentions))
|
||||
= check_box_tag 'settings[auto_mentions]', 1, @settings[:auto_mentions].to_i == 1
|
||||
p
|
||||
= content_tag(:label, l(:label_settings_default_mentions))
|
||||
= text_field_tag('settings[default_mentions]', @settings[:default_mentions], size: 30)
|
||||
em.info = t(:default_mentionsl_info)
|
||||
p
|
||||
= content_tag(:label, l(:label_settings_display_watchers))
|
||||
= check_box_tag 'settings[display_watchers]', 1, @settings[:display_watchers].to_i == 1
|
||||
p
|
||||
= content_tag(:label, l(:label_settings_post_updates))
|
||||
= check_box_tag 'settings[post_updates]', 1, @settings[:post_updates].to_i == 1
|
||||
p
|
||||
= content_tag(:label, l(:label_settings_new_include_description))
|
||||
= check_box_tag 'settings[new_include_description]', 1, @settings[:new_include_description].to_i == 1
|
||||
p
|
||||
= content_tag(:label, l(:label_settings_updated_include_description))
|
||||
= check_box_tag 'settings[updated_include_description]', 1, @settings[:updated_include_description].to_i == 1
|
||||
p
|
||||
= content_tag(:label, l(:label_settings_post_private_issues))
|
||||
= check_box_tag 'settings[post_private_issues]', 1, @settings[:post_private_issues].to_i == 1
|
||||
p
|
||||
= content_tag(:label, l(:label_settings_post_private_notes))
|
||||
= check_box_tag 'settings[post_private_notes]', 1, @settings[:post_private_notes].to_i == 1
|
||||
|
||||
br
|
||||
h3 = l(:label_wiki)
|
||||
.info = t(:messenger_wiki_intro)
|
||||
br
|
||||
p
|
||||
= content_tag(:label, l(:label_settings_post_wiki))
|
||||
= check_box_tag 'settings[post_wiki]', 1, @settings[:post_wiki].to_i == 1
|
||||
p
|
||||
= content_tag(: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
|
||||
br
|
||||
h3 = l(:label_db_entry_plural)
|
||||
.info = t(:messenger_db_intro)
|
||||
br
|
||||
p
|
||||
= content_tag(:label, l(:label_settings_post_db))
|
||||
= check_box_tag 'settings[post_db]', 1, @settings[:post_db].to_i == 1
|
||||
p
|
||||
= content_tag(:label, l(:label_settings_post_db_updates))
|
||||
= check_box_tag 'settings[post_db_updates]', 1, @settings[:post_db_updates].to_i == 1
|
||||
p
|
||||
= content_tag(: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
|
||||
br
|
||||
h3 = l(:label_contact_plural)
|
||||
.info = t(:messenger_contacts_intro)
|
||||
br
|
||||
p
|
||||
= content_tag(:label, l(:label_settings_post_contact))
|
||||
= check_box_tag 'settings[post_contact]', 1, @settings[:post_contact].to_i == 1
|
||||
p
|
||||
= content_tag(:label, l(:label_settings_post_contact_updates))
|
||||
= check_box_tag 'settings[post_contact_updates]', 1, @settings[:post_contact_updates].to_i == 1
|
||||
p
|
||||
= content_tag(: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')
|
||||
br
|
||||
h3 = l(:label_password_plural)
|
||||
.info = t(:messenger_passwords_intro)
|
||||
br
|
||||
p
|
||||
= content_tag(:label, l(:label_settings_post_password))
|
||||
= check_box_tag 'settings[post_password]', 1, @settings[:post_password].to_i == 1
|
||||
p
|
||||
= content_tag(:label, l(:label_settings_post_password_updates))
|
||||
= check_box_tag 'settings[post_password_updates]', 1, @settings[:post_password_updates].to_i == 1
|
||||
1
assets/javascripts/.eslintignore
Normal file
1
assets/javascripts/.eslintignore
Normal file
@@ -0,0 +1 @@
|
||||
# eslint ignore file
|
||||
1
assets/stylesheets/.stylelintignore
Normal file
1
assets/stylesheets/.stylelintignore
Normal file
@@ -0,0 +1 @@
|
||||
# stylelint ignore file
|
||||
@@ -1,6 +1,7 @@
|
||||
# German strings
|
||||
de:
|
||||
permission_manage_messenger: Messenger verwalten
|
||||
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}*"
|
||||
@@ -11,6 +12,7 @@ de:
|
||||
label_messenger_password_created: "[%{project_url}] Kennwort %{url} erstellt von *%{user}*"
|
||||
label_messenger_password_updated: "[%{project_url}] Kennwort %{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
|
||||
label_messenger_settings_disabled: Deaktiviert
|
||||
label_messenger_settings_enabled: Aktiviert
|
||||
@@ -28,10 +30,12 @@ de:
|
||||
label_settings_new_include_description: Neue Ticketeschreibung?
|
||||
label_settings_post_contact_updates: Kontakt Updates?
|
||||
label_settings_post_contact: Neue Kontakte?
|
||||
label_settings_post_db_updates: DB entry Updates?
|
||||
label_settings_post_db: Neue DB entries?
|
||||
label_settings_post_db_updates: DB Einträge Updates?
|
||||
label_settings_post_db: Neue DB Einträge?
|
||||
label_settings_post_password_updates: Passwort Updates?
|
||||
label_settings_post_password: Neue Passwörter?
|
||||
label_settings_post_private_contacts: Private Kontakte?
|
||||
label_settings_post_private_db: Private DB Einträge?
|
||||
label_settings_post_private_issues: Private Ticket Updates?
|
||||
label_settings_post_private_notes: Private Notizen?
|
||||
label_settings_post_updates: Ticket Updates?
|
||||
@@ -48,5 +52,4 @@ de:
|
||||
messenger_url_info_html: 'Generiere eine <a target="_blank" href="https://github.com/AlphaNodes/redmine_messenger#prepare-your-messenger-service">Incoming WebHook</a> URL vom Messenger Service. Um nur aus bestimmten Projekten Nachrichten zu versenden, kann diese URL leer bleiben und in den Projekteinstellungen gesetzt werden.'
|
||||
messenger_verify_ssl_info_html: 'Falls der Messenger Service ein ungültiges oder selbst erstelltes (self-signed) SSL Zertifikat verwendet bitte deaktivieren.'
|
||||
messenger_wiki_intro: Legen Sie fest welche Einträge oder Änderungen für Wikis im angegebenen Messenger Channel versendet werden.
|
||||
label_messenger_setting: Messenger Einstellung
|
||||
default_mentionsl_info: Benutzer, die immer mit Mentions benachrichtet werden sollen. Mehrere Namen können mit Komma getrennt angegeben werden (z.B. @all, @here).
|
||||
permission_manage_messenger: Messenger verwalten
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# English strings
|
||||
en:
|
||||
permission_manage_messenger: Manage messenger
|
||||
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}*"
|
||||
@@ -11,6 +12,7 @@ en:
|
||||
label_messenger_password_created: "[%{project_url}] Kennwort %{url} created by *%{user}*"
|
||||
label_messenger_password_updated: "[%{project_url}] Kennwort %{url} updated by *%{user}*"
|
||||
label_messenger_project_text_field_info: Leave it blank for system default.
|
||||
label_messenger_setting: Messenger Settings
|
||||
label_messenger_settings_default: System default
|
||||
label_messenger_settings_disabled: Disabled
|
||||
label_messenger_settings_enabled: Enabled
|
||||
@@ -32,6 +34,8 @@ en:
|
||||
label_settings_post_db: DB entry added?
|
||||
label_settings_post_password_updates: Password updates?
|
||||
label_settings_post_password: Password added?
|
||||
label_settings_post_private_contacts: Private contacts?
|
||||
label_settings_post_private_db: Private DB entries?
|
||||
label_settings_post_private_issues: Private issue updates?
|
||||
label_settings_post_private_notes: Private notes updates?
|
||||
label_settings_post_updates: Issue updates?
|
||||
@@ -48,5 +52,4 @@ en:
|
||||
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_wiki_intro: Activate the changes for Wikis that should be sent to the pre-defined Messenger channel.
|
||||
label_messenger_setting: Messenger Settings
|
||||
default_mentionsl_info: Default people to notify, comma separated (e.g. @all, @here)
|
||||
permission_manage_messenger: Manage messenger
|
||||
|
||||
55
config/locales/fr.yml
Normal file
55
config/locales/fr.yml
Normal file
@@ -0,0 +1,55 @@
|
||||
# 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}*"
|
||||
label_messenger_db_entry_updated: "[%{project_url}] Entrée de base de données %{url} mis à jour par *%{user}*"
|
||||
label_messenger_default_not_visible: Le paramètre par défaut n'est pas visible pour des raisons de sécurité
|
||||
label_messenger_issue_created: "[%{project_url}] Ticket %{url} créé par *%{user}*"
|
||||
label_messenger_issue_updated: "[%{project_url}] Ticket %{url} mis à jour par *%{user}*"
|
||||
label_messenger_password_created: "[%{project_url}] Mot de passe %{url} créé par *%{user}*"
|
||||
label_messenger_password_updated: "[%{project_url}] Mot de passe %{url} mis à jour par *%{user}*"
|
||||
label_messenger_project_text_field_info: Laissez ce champ vide pour le système par défaut.
|
||||
label_messenger_setting: Paramètres de messagerie
|
||||
label_messenger_settings_default: Choix de l'option
|
||||
label_messenger_settings_disabled: Désactivé
|
||||
label_messenger_settings_enabled: Activé
|
||||
label_messenger_wiki_created: "[%{project_url}] Wiki %{url} créé par *%{user}*"
|
||||
label_messenger_wiki_updated: "[%{project_url}] Wiki %{url} mis à jour par *%{user}*"
|
||||
label_messenger: Messenger
|
||||
label_settings_auto_mentions: Convert names to mentions ?
|
||||
label_settings_default_mentions: Default people for mentions
|
||||
label_settings_display_watchers: Afficher l'utilisateur assigné au ticket ?
|
||||
label_settings_messenger_channel: Messenger - Nom du salon
|
||||
label_settings_messenger_icon: Messenger - Icône affiché
|
||||
label_settings_messenger_url: Messenger - URL WebHook entrant
|
||||
label_settings_messenger_username: Messenger - Nom du robot
|
||||
label_settings_messenger_verify_ssl: Vérifier SSL
|
||||
label_settings_new_include_description: Description du nouveau ticket ?
|
||||
label_settings_post_contact_updates: Mises à jour de contact ?
|
||||
label_settings_post_contact: Contact ajouté ?
|
||||
label_settings_post_db_updates: Mises à jour des entrées de base de données ?
|
||||
label_settings_post_db: Entrée de base de données ajoutée ?
|
||||
label_settings_post_password_updates: Mises à jour du mot de passe ?
|
||||
label_settings_post_password: Mot de passe ajouté ?
|
||||
label_settings_post_private_contacts: Contacts privés ?
|
||||
label_settings_post_private_db: Entrées de base de données privées ?
|
||||
label_settings_post_private_issues: Mises à jour des tickets privés?
|
||||
label_settings_post_private_notes: Mises à jour des notes privées ?
|
||||
label_settings_post_updates: Publier pour chaque mises à jour ?
|
||||
label_settings_post_wiki_updates: Mises à jour du wiki ?
|
||||
label_settings_post_wiki: Post Wiki ajouté ?
|
||||
label_settings_updated_include_description: Description suite à une mise à jour ?
|
||||
messenger_channel_info_html: 'Vous devez spécifier le canal à utiliser. Vous pouvez définir plusieurs canaux, séparés par une virgule.'
|
||||
messenger_contacts_intro: Activer les modifications pour les contacts à envoyer au canal Messenger prédéfini.
|
||||
messenger_db_intro: Activer les modifications pour la base de données à envoyer au canal Messenger prédéfini.
|
||||
messenger_issue_intro: Activer les modifications pour les tickets à envoyer au canal Messenger prédéfini.
|
||||
messenger_passwords_intro: Activez les modifications pour les mots de passe devant être envoyés au canal Messenger prédéfini.
|
||||
messenger_settings_intro: "Laissez l'URL de Messenger dans la zone d'administration vide afin de ne pas envoyer de messages de Redmine à Messenger. Peu importe ce que vous avez configuré ici. Si vous souhaitez envoyer des messages de tous les projets Redmine à Messenger, renseignez l’URL. Les messages seront envoyés au canal spécifique. Si vous souhaitez uniquement être averti par certains des projets (pas tous), laissez l'URL du messager ici vide et accédez à la configuration du projet spécifique."
|
||||
messenger_settings_project_intro: "Si vous laissez vide l'URL de Messenger dans la zone d'administration au cas où vous ne seriez pas averti globalement de toutes les modifications apportées au projet, vous pouvez configurer votre URL Messenger dans les paramètres du projet."
|
||||
messenger_url_info_html: 'Générer une <a target="_blank" href="https://github.com/AlphaNodes/redmine_messenger#prepare-your-messenger-service">Incoming WebHook</a> URL du service de messagerie. Laissez-le vide si vous souhaitez uniquement activer des projets spécifiques avec des paramètres de projet.'
|
||||
messenger_verify_ssl_info_html: 'Si votre service Messenger utilise un certificat SSL non valide ou auto-signé, désactivez-le.'
|
||||
messenger_wiki_intro: Activez les modifications pour les wikis à envoyer au canal Messenger prédéfini.
|
||||
permission_manage_messenger: Gérer messenger
|
||||
@@ -1,6 +1,7 @@
|
||||
# Japanese strings
|
||||
ja:
|
||||
permission_manage_messenger: メッセンジャーの管理
|
||||
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}*"
|
||||
@@ -11,6 +12,7 @@ ja:
|
||||
label_messenger_password_created: "[%{project_url}] Kennwort %{url} created by *%{user}*"
|
||||
label_messenger_password_updated: "[%{project_url}] Kennwort %{url} updated by *%{user}*"
|
||||
label_messenger_project_text_field_info: デフォルトの設定を使う場合空欄にしてください。
|
||||
label_messenger_setting: メッセンジャーの設定
|
||||
label_messenger_settings_default: デフォルト
|
||||
label_messenger_settings_disabled: 無効
|
||||
label_messenger_settings_enabled: 有効
|
||||
@@ -32,6 +34,8 @@ ja:
|
||||
label_settings_post_db: DB entry added?
|
||||
label_settings_post_password_updates: Password updates?
|
||||
label_settings_post_password: Password added?
|
||||
label_settings_post_private_contacts: Private contacts?
|
||||
label_settings_post_private_db: Private DB entries?
|
||||
label_settings_post_private_issues: プライベートチケットの更新
|
||||
label_settings_post_private_notes: プライベート注記の更新
|
||||
label_settings_post_updates: チケットの更新
|
||||
@@ -48,5 +52,4 @@ ja:
|
||||
messenger_url_info_html: 'メッセンジャー サービスで <a target="_blank" href="https://github.com/AlphaNodes/redmine_messenger#prepare-your-messenger-service">内向きのウェブフック</a>のURLを作成して下さい。プロジェクト毎に設定を変えたい場合は空欄として下さい。'
|
||||
messenger_verify_ssl_info_html: 'メッセンジャー サービスが自己署名証明書や不正な証明書を使っている場合、無効として下さい。'
|
||||
messenger_wiki_intro: メッセンジャーに送信するWikiのイベントにチェックを入れて下さい。
|
||||
label_messenger_setting: メッセンジャーの設定
|
||||
default_mentionsl_info: Default people to notify, comma separated (e.g. @all, @here)
|
||||
permission_manage_messenger: メッセンジャーの管理
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# Redmine Messenger plugin for Redmine
|
||||
# Plugin's routes
|
||||
# See: http://guides.rubyonrails.org/routing.html
|
||||
|
||||
RedmineApp::Application.routes.draw do
|
||||
match 'projects/:id/messenger_settings/save',
|
||||
to: 'messenger_settings#save',
|
||||
via: %i[post put patch]
|
||||
# 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]
|
||||
end
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
# Redmine Messenger plugin for Redmine
|
||||
|
||||
class CreateMessengerSettings < ActiveRecord::Migration
|
||||
class CreateMessengerSettings < Rails.version < '5.2' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :messenger_settings do |t|
|
||||
t.references :project, null: false, index: true
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
# Redmine Messenger plugin for Redmine
|
||||
|
||||
class AddDefaultMentions < ActiveRecord::Migration
|
||||
class AddDefaultMentions < Rails.version < '5.2' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :messenger_settings, :default_mentions, :string
|
||||
end
|
||||
|
||||
6
db/migrate/003_add_private_settings.rb
Normal file
6
db/migrate/003_add_private_settings.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class AddPrivateSettings < Rails.version < '5.2' ? ActiveRecord::Migration : 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
|
||||
end
|
||||
end
|
||||
14
init.rb
14
init.rb
@@ -1,4 +1,4 @@
|
||||
# Redmine Messenger plugin for Redmine
|
||||
raise "\n\033[31mredmine_messenger requires ruby 2.3 or newer. Please update your ruby version.\033[0m" if RUBY_VERSION < '2.3'
|
||||
|
||||
require 'redmine'
|
||||
require 'redmine_messenger'
|
||||
@@ -8,12 +8,12 @@ Redmine::Plugin.register :redmine_messenger do
|
||||
author 'AlphaNodes GmbH'
|
||||
url 'https://github.com/alphanodes/redmine_messenger'
|
||||
author_url 'https://alphanodes.com/'
|
||||
description 'Messenger integration for Slack, Rocketchat and Mattermost support'
|
||||
version '1.0.1'
|
||||
description 'Messenger integration for Slack, Discord, Rocketchat and Mattermost support'
|
||||
version '1.0.5'
|
||||
|
||||
requires_redmine version_or_higher: '3.0.0'
|
||||
|
||||
permission :manage_messenger, projects: :settings, messenger_settings: :save
|
||||
permission :manage_messenger, projects: :settings, messenger_settings: :update
|
||||
|
||||
settings default: {
|
||||
messenger_url: '',
|
||||
@@ -27,8 +27,10 @@ Redmine::Plugin.register :redmine_messenger do
|
||||
post_updates: '1',
|
||||
new_include_description: '1',
|
||||
updated_include_description: '1',
|
||||
post_private_issues: '1',
|
||||
post_private_notes: '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',
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# Redmine Messenger plugin for Redmine
|
||||
|
||||
Rails.configuration.to_prepare do
|
||||
module RedmineMessenger
|
||||
REDMINE_CONTACTS_SUPPORT = Redmine::Plugin.installed?('redmine_contacts') ? true : false
|
||||
@@ -8,25 +6,38 @@ Rails.configuration.to_prepare do
|
||||
REDMINE_PASSWORDS_SUPPORT = Redmine::Plugin.installed?('redmine_passwords') ? true : false
|
||||
|
||||
def self.settings
|
||||
ActionController::Parameters.new(Setting[:plugin_redmine_messenger])
|
||||
if Setting[:plugin_redmine_messenger].class == Hash
|
||||
if Rails.version >= '5.2'
|
||||
# convert Rails 4 data
|
||||
new_settings = ActiveSupport::HashWithIndifferentAccess.new(Setting[:plugin_redmine_messenger])
|
||||
Setting.plugin_redmine_messenger = new_settings
|
||||
new_settings
|
||||
else
|
||||
ActionController::Parameters.new(Setting[:plugin_redmine_messenger])
|
||||
end
|
||||
else
|
||||
# Rails 5 uses ActiveSupport::HashWithIndifferentAccess
|
||||
Setting[:plugin_redmine_messenger]
|
||||
end
|
||||
end
|
||||
|
||||
def self.setting?(value)
|
||||
return true if settings[value].to_i == 1
|
||||
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
# Patches
|
||||
require_dependency 'redmine_messenger/patches/issue_patch'
|
||||
require_dependency 'redmine_messenger/patches/wiki_page_patch'
|
||||
require_dependency 'redmine_messenger/patches/projects_helper_patch'
|
||||
|
||||
require 'redmine_messenger/patches/contact_patch' if RedmineMessenger::REDMINE_CONTACTS_SUPPORT
|
||||
require 'redmine_messenger/patches/db_entry_patch' if RedmineMessenger::REDMINE_DB_SUPPORT
|
||||
require 'redmine_messenger/patches/password_patch' if Redmine::Plugin.installed?('redmine_passwords')
|
||||
Issue.send(:include, RedmineMessenger::Patches::IssuePatch)
|
||||
WikiPage.send(:include, RedmineMessenger::Patches::WikiPagePatch)
|
||||
ProjectsController.send :helper, MessengerProjectsHelper
|
||||
Contact.send(:include, RedmineMessenger::Patches::ContactPatch) if RedmineMessenger::REDMINE_CONTACTS_SUPPORT
|
||||
DbEntry.send(:include, RedmineMessenger::Patches::DbEntryPatch) if RedmineMessenger::REDMINE_DB_SUPPORT
|
||||
Password.send(:include, RedmineMessenger::Patches::PasswordPatch) if Redmine::Plugin.installed?('redmine_passwords')
|
||||
|
||||
# Global helpers
|
||||
require_dependency 'redmine_messenger/helpers'
|
||||
ActionView::Base.send :include, RedmineMessenger::Helpers
|
||||
|
||||
# Hooks
|
||||
require_dependency 'redmine_messenger/hooks'
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# Redmine Messenger plugin for Redmine
|
||||
|
||||
module RedmineMessenger
|
||||
module Helpers
|
||||
def project_messenger_options(active)
|
||||
@@ -17,5 +15,3 @@ module RedmineMessenger
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ActionView::Base.send :include, RedmineMessenger::Helpers
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# Redmine Messenger plugin for Redmine
|
||||
|
||||
module RedmineMessenger
|
||||
class MessengerListener < Redmine::Hook::Listener
|
||||
def model_changeset_scan_commit_for_issue_ids_pre_issue_update(context = {})
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# Redmine Messenger plugin for Redmine
|
||||
|
||||
module RedmineMessenger
|
||||
module Patches
|
||||
module ContactPatch
|
||||
@@ -14,12 +12,15 @@ module RedmineMessenger
|
||||
module InstanceMethods
|
||||
def send_messenger_create
|
||||
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.object_url project}|#{ERB::Util.html_escape(project)}>",
|
||||
url: "<#{Messenger.object_url self}|#{name}>",
|
||||
@@ -29,12 +30,15 @@ module RedmineMessenger
|
||||
|
||||
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.object_url project}|#{ERB::Util.html_escape(project)}>",
|
||||
url: "<#{Messenger.object_url self}|#{name}>",
|
||||
@@ -45,7 +49,3 @@ module RedmineMessenger
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless Contact.included_modules.include? RedmineMessenger::Patches::ContactPatch
|
||||
Contact.send(:include, RedmineMessenger::Patches::ContactPatch)
|
||||
end
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# Redmine Messenger plugin for Redmine
|
||||
|
||||
module RedmineMessenger
|
||||
module Patches
|
||||
module DbEntryPatch
|
||||
@@ -14,12 +12,15 @@ module RedmineMessenger
|
||||
module InstanceMethods
|
||||
def send_messenger_create
|
||||
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.object_url project}|#{ERB::Util.html_escape(project)}>",
|
||||
url: "<#{Messenger.object_url self}|#{name}>",
|
||||
@@ -29,12 +30,15 @@ module RedmineMessenger
|
||||
|
||||
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.object_url project}|#{ERB::Util.html_escape(project)}>",
|
||||
url: "<#{Messenger.object_url self}|#{name}>",
|
||||
@@ -45,7 +49,3 @@ module RedmineMessenger
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless DbEntry.included_modules.include? RedmineMessenger::Patches::DbEntryPatch
|
||||
DbEntry.send(:include, RedmineMessenger::Patches::DbEntryPatch)
|
||||
end
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# Redmine Messenger plugin for Redmine
|
||||
|
||||
module RedmineMessenger
|
||||
module Patches
|
||||
module IssuePatch
|
||||
@@ -23,23 +21,21 @@ module RedmineMessenger
|
||||
|
||||
attachment = {}
|
||||
if description.present? && Messenger.setting_for_project(project, :new_include_description)
|
||||
attachment[:text] = ERB::Util.html_escape(description)
|
||||
attachment[:text] = Messenger.markup_format(description)
|
||||
end
|
||||
attachment[:fields] = [{ title: I18n.t(:field_status),
|
||||
value: ERB::Util.html_escape(status.to_s),
|
||||
short: true },
|
||||
{ title: I18n.t(:field_priority),
|
||||
value: ERB::Util.html_escape(priority.to_s),
|
||||
short: true }]
|
||||
if assigned_to.present?
|
||||
attachment[:fields] << { title: I18n.t(:field_assigned_to),
|
||||
value: ERB::Util.html_escape(assigned_to.to_s),
|
||||
short: true }
|
||||
end
|
||||
attachment[:fields] = [{
|
||||
title: I18n.t(:field_status),
|
||||
value: ERB::Util.html_escape(status.to_s),
|
||||
short: true
|
||||
}, {
|
||||
title: I18n.t(:field_priority),
|
||||
value: ERB::Util.html_escape(priority.to_s),
|
||||
short: true
|
||||
}, {
|
||||
title: I18n.t(:field_assigned_to),
|
||||
value: ERB::Util.html_escape(assigned_to.to_s),
|
||||
short: true
|
||||
}]
|
||||
|
||||
if RedmineMessenger.setting?(:display_watchers)
|
||||
if RedmineMessenger.setting?(:display_watchers) && watcher_users.count.positive?
|
||||
attachment[:fields] << {
|
||||
title: I18n.t(:field_watcher),
|
||||
value: ERB::Util.html_escape(watcher_users.join(', ')),
|
||||
@@ -68,9 +64,25 @@ module RedmineMessenger
|
||||
|
||||
attachment = {}
|
||||
if current_journal.notes.present? && Messenger.setting_for_project(project, :updated_include_description)
|
||||
attachment[:text] = ERB::Util.html_escape(current_journal.notes)
|
||||
attachment[:text] = Messenger.markup_format(current_journal.notes)
|
||||
end
|
||||
|
||||
fields = current_journal.details.map { |d| Messenger.detail_to_field d }
|
||||
if status_id != status_id_was
|
||||
fields << { title: I18n.t(:field_status),
|
||||
value: ERB::Util.html_escape(status.to_s),
|
||||
short: true }
|
||||
end
|
||||
if priority_id != priority_id_was
|
||||
fields << { title: I18n.t(:field_priority),
|
||||
value: ERB::Util.html_escape(priority.to_s),
|
||||
short: true }
|
||||
end
|
||||
if assigned_to.present?
|
||||
fields << { title: I18n.t(:field_assigned_to),
|
||||
value: ERB::Util.html_escape(assigned_to.to_s),
|
||||
short: true }
|
||||
end
|
||||
attachment[:fields] = fields if fields.any?
|
||||
|
||||
Messenger.speak(l(:label_messenger_issue_updated,
|
||||
@@ -94,7 +106,3 @@ module RedmineMessenger
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless WikiPage.included_modules.include? RedmineMessenger::Patches::WikiPagePatch
|
||||
WikiPage.send(:include, RedmineMessenger::Patches::WikiPagePatch)
|
||||
end
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# Redmine Messenger plugin for Redmine
|
||||
|
||||
module RedmineMessenger
|
||||
module Patches
|
||||
module PasswordPatch
|
||||
@@ -14,12 +12,15 @@ module RedmineMessenger
|
||||
module InstanceMethods
|
||||
def send_messenger_create
|
||||
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.object_url project}|#{ERB::Util.html_escape(project)}>",
|
||||
url: "<#{Messenger.object_url self}|#{name}>",
|
||||
@@ -29,12 +30,15 @@ module RedmineMessenger
|
||||
|
||||
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.object_url project}|#{ERB::Util.html_escape(project)}>",
|
||||
url: "<#{Messenger.object_url self}|#{name}>",
|
||||
@@ -45,7 +49,3 @@ module RedmineMessenger
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless Password.included_modules.include? RedmineMessenger::Patches::PasswordPatch
|
||||
Password.send(:include, RedmineMessenger::Patches::PasswordPatch)
|
||||
end
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
# Redmine Messenger plugin for Redmine
|
||||
|
||||
module RedmineMessenger
|
||||
module Patches
|
||||
module ProjectsHelperPatch
|
||||
def self.included(base)
|
||||
base.send(:include, InstanceMethods)
|
||||
base.class_eval do
|
||||
alias_method_chain :project_settings_tabs, :messenger
|
||||
end
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
def project_settings_tabs_with_messenger
|
||||
tabs = project_settings_tabs_without_messenger
|
||||
action = { name: 'messenger',
|
||||
controller: 'messenger_settings',
|
||||
action: :show,
|
||||
partial: 'messenger_settings/show',
|
||||
label: :label_messenger }
|
||||
|
||||
tabs << action if User.current.allowed_to?(:manage_messenger, @project)
|
||||
tabs
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless ProjectsHelper.included_modules.include?(RedmineMessenger::Patches::ProjectsHelperPatch)
|
||||
ProjectsHelper.send(:include, RedmineMessenger::Patches::ProjectsHelperPatch)
|
||||
end
|
||||
@@ -1,5 +1,3 @@
|
||||
# Redmine Messenger plugin for Redmine
|
||||
|
||||
module RedmineMessenger
|
||||
module Patches
|
||||
module WikiPagePatch
|
||||
@@ -14,12 +12,14 @@ module RedmineMessenger
|
||||
module InstanceMethods
|
||||
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.object_url project}|#{ERB::Util.html_escape(project)}>",
|
||||
url: "<#{Messenger.object_url self}|#{title}>",
|
||||
@@ -29,6 +29,7 @@ module RedmineMessenger
|
||||
|
||||
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
|
||||
@@ -37,9 +38,9 @@ module RedmineMessenger
|
||||
return unless channels.present? && url
|
||||
|
||||
attachment = nil
|
||||
unless content.comments.empty?
|
||||
if !content.nil? && content.comments.present?
|
||||
attachment = {}
|
||||
attachment[:text] = ERB::Util.html_escape(content.comments.to_s)
|
||||
attachment[:text] = Messenger.markup_format(content.comments.to_s)
|
||||
end
|
||||
|
||||
Messenger.speak(l(:label_messenger_wiki_updated,
|
||||
@@ -52,7 +53,3 @@ module RedmineMessenger
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless Issue.included_modules.include? RedmineMessenger::Patches::IssuePatch
|
||||
Issue.send(:include, RedmineMessenger::Patches::IssuePatch)
|
||||
end
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# Redmine Messenger plugin for Redmine
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class CommonViewsTest < Redmine::IntegrationTest
|
||||
@@ -20,10 +18,6 @@ class CommonViewsTest < Redmine::IntegrationTest
|
||||
|
||||
def setup
|
||||
RedmineMessenger::TestCase.prepare
|
||||
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
@request.env['HTTP_REFERER'] = '/'
|
||||
end
|
||||
|
||||
test 'View user' do
|
||||
|
||||
8
test/integration/routing_test.rb
Normal file
8
test/integration/routing_test.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class RoutingTest < Redmine::RoutingTest
|
||||
test 'routing messenger' do
|
||||
should_route 'GET /projects/1/settings/messenger' => 'projects#settings', id: '1', tab: 'messenger'
|
||||
should_route 'PUT /projects/1/messenger_setting' => 'messenger_settings#update', project_id: '1'
|
||||
end
|
||||
end
|
||||
4
test/support/additional_environment.rb
Normal file
4
test/support/additional_environment.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
# for travis debugging
|
||||
# config.logger = Logger.new(STDOUT)
|
||||
# config.logger.level = Logger::INFO
|
||||
# config.log_level = :info
|
||||
8
test/support/database-postgresql-travis.yml
Normal file
8
test/support/database-postgresql-travis.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
test:
|
||||
adapter: postgresql
|
||||
encoding: unicode
|
||||
pool: 5
|
||||
database: travis_ci_test
|
||||
user: postgres
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Redmine Messenger plugin for Redmine
|
||||
$VERBOSE = nil
|
||||
|
||||
unless ENV['SKIP_COVERAGE']
|
||||
require 'simplecov'
|
||||
@@ -20,29 +20,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')
|
||||
module RedmineMessenger
|
||||
class TestCase
|
||||
include ActionDispatch::TestProcess
|
||||
def self.plugin_fixtures(plugin, *fixture_names)
|
||||
plugin_fixture_path = "#{Redmine::Plugin.find(plugin).directory}/test/fixtures"
|
||||
if fixture_names.first == :all
|
||||
fixture_names = Dir["#{plugin_fixture_path}/**/*.{yml}"]
|
||||
fixture_names.map! { |f| f[(plugin_fixture_path.size + 1)..-5] }
|
||||
else
|
||||
fixture_names = fixture_names.flatten.map(&:to_s)
|
||||
end
|
||||
|
||||
ActiveRecord::Fixtures.create_fixtures(plugin_fixture_path, fixture_names)
|
||||
end
|
||||
|
||||
def uploaded_test_file(name, mime)
|
||||
ActionController::TestUploadedFile.new(ActiveSupport::TestCase.fixture_path + "/files/#{name}", mime, true)
|
||||
end
|
||||
|
||||
def self.arrays_equal?(a1, a2)
|
||||
(a1 - a2) - (a2 - a1) == []
|
||||
end
|
||||
|
||||
def self.create_fixtures(fixtures_directory, table_names, _class_names = {})
|
||||
ActiveRecord::FixtureSet.create_fixtures(fixtures_directory, table_names, _class_names = {})
|
||||
end
|
||||
|
||||
def self.prepare
|
||||
Role.where(id: [1, 2]).each do |r|
|
||||
|
||||
@@ -1,42 +1,38 @@
|
||||
# Redmine Messenger plugin for Redmine
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
module Redmine
|
||||
class I18nTest < ActiveSupport::TestCase
|
||||
include Redmine::I18n
|
||||
class I18nTest < ActiveSupport::TestCase
|
||||
include Redmine::I18n
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def teardown
|
||||
set_language_if_valid 'en'
|
||||
end
|
||||
def teardown
|
||||
set_language_if_valid 'en'
|
||||
end
|
||||
|
||||
def test_valid_languages
|
||||
assert valid_languages.is_a?(Array)
|
||||
assert valid_languages.first.is_a?(Symbol)
|
||||
end
|
||||
def test_valid_languages
|
||||
assert valid_languages.is_a?(Array)
|
||||
assert valid_languages.first.is_a?(Symbol)
|
||||
end
|
||||
|
||||
def test_locales_validness
|
||||
lang_files_count = Dir[Rails.root.join('plugins',
|
||||
'redmine_messenger',
|
||||
'config',
|
||||
'locales',
|
||||
'*.yml')].size
|
||||
assert_equal lang_files_count, 3
|
||||
valid_languages.each do |lang|
|
||||
assert set_language_if_valid(lang)
|
||||
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')
|
||||
def test_locales_validness
|
||||
lang_files_count = Dir[Rails.root.join('plugins',
|
||||
'redmine_messenger',
|
||||
'config',
|
||||
'locales',
|
||||
'*.yml')].size
|
||||
assert_equal lang_files_count, 4
|
||||
valid_languages.each do |lang|
|
||||
assert set_language_if_valid(lang)
|
||||
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')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# Redmine Messenger plugin for Redmine
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class IssueTest < ActiveSupport::TestCase
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
# This file is a part of redmine_reporting,
|
||||
# a reporting and statistics plugin for Redmine.
|
||||
#
|
||||
# Copyright (c) 2016-2017 AlphaNodes GmbH
|
||||
# https://alphanodes.com
|
||||
#
|
||||
# redmine_reporting is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_reporting is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with redmine_reporting. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class ProjectTest < ActiveSupport::TestCase
|
||||
|
||||
Reference in New Issue
Block a user