Skip to content

Commit

Permalink
Merge branch 'release/0.9.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
haru committed Jul 16, 2022
2 parents a0c57cb + bf86ce6 commit 43c6e4c
Show file tree
Hide file tree
Showing 15 changed files with 179 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ services:
# Update 'VARIANT' to pick a version of Ruby: 3, 3.0, 2, 2.7, 2.6
# Append -bullseye or -buster to pin to an OS version.
# Use -bullseye variants on local arm64/Apple Silicon.
VARIANT: "2.7"
VARIANT: "3.0"
# Optional Node.js version to install
NODE_VERSION: "lts/*"
REDMINE_VERSION: "4.2-stable"
REDMINE_VERSION: "5.0-stable"

volumes:
- ..:/usr/local/redmine/plugins/redmine_wiki_extensions:cached
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,25 @@ jobs:
strategy:
matrix:
db: [sqlite3, mysql, postgres]
ruby_version: [2.4, 2.5, 2.6, 2.7, 3.0]
redmine_version: [4.1-stable, 4.2-stable, master]
ruby_version: [2.4, 2.5, 2.6, 2.7, 3.0, 3.1]
redmine_version: [4.1-stable, 4.2-stable, 5.0-stable, master]
exclude:
- ruby_version: 2.4
redmine_version: master
- ruby_version: 2.4
redmine_version: 5.0-stable
- ruby_version: 2.5
redmine_version: master
- ruby_version: 2.7
redmine_version: 4.1-stable
- ruby_version: 3.0
redmine_version: 4.1-stable
- ruby_version: 3.0
redmine_version: 4.2-stable
- ruby_version: 3.1
redmine_version: 4.1-stable
- ruby_version: 3.1
redmine_version: 4.2-stable
services:
mysql:
image: mysql:5.7
Expand Down
21 changes: 21 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# List the start up tasks. Learn more https://www.gitpod.io/docs/config-start-tasks/
tasks:
- init: sh -x ./.gitpod/setup.sh
command: pwd; sh -x /workspace/*/.gitpod/start.sh
env:
REDMINE_VERSION: '5.0-stable'

# List the ports to expose. Learn more https://www.gitpod.io/docs/config-ports/
ports:
- port: 3000
onOpen: open-browser

workspaceLocation: "./redmine"

vscode:
extensions:
- bung87.rails
- rebornix.ruby
- aliariff.vscode-erb-beautify
- mbessey.vscode-rufo
19 changes: 19 additions & 0 deletions .gitpod/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Default setup is given for MySQL 5.7.7 or later.
# Examples for PostgreSQL, SQLite3 and SQL Server can be found at the end.
# Line indentation must be 2 spaces (no tabs).

production:
adapter: sqlite3
database: db/redmine.sqlite3

development:
adapter: sqlite3
database: db/redmine_dev.sqlite3

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/redmine_test.sqlite3

11 changes: 11 additions & 0 deletions .gitpod/gitpod.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"folders": [
{
"path": "."
},
{
"path": "../__PLUGIN__NAME"
}
],
"settings": {}
}
2 changes: 2 additions & 0 deletions .gitpod/ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vscode/launch.json
/gitpod.code-workspace
33 changes: 33 additions & 0 deletions .gitpod/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [


{
"name": "Rails server",
"type": "Ruby",
"request": "launch",
"program": "${workspaceRoot}/bin/rails",
"args": [
"server"
],
"useBundler": true
},
{
"name": "Plugin test",
"type": "Ruby",
"request": "launch",
"program": "${workspaceRoot}/bin/rake",
"args": [
"redmine:plugins:test"
],
"env": {
"RAILS_ENV": "test"
},
"useBundler": true
}
]
}
30 changes: 30 additions & 0 deletions .gitpod/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh
cd $(dirname "$0") || exit
GITPODDIR=$(pwd)
IGNOREDIR="$HOME"/.config/git
mkdir -p "$IGNOREDIR"
cp "$GITPODDIR"/ignore "$IGNOREDIR"
cd ..
BASEDIR=$(pwd)

if [ -f Gemfile_for_test ]; then
cp Gemfile_for_test Gemfile
fi
cd ..
REDMINEDIR=$(pwd)/redmine
if [ ! -d redmine ]; then
git clone https://github.com/redmine/redmine.git -b "$REDMINE_VERSION"
cd redmine || exit
mv .git .git.org
cd "$REDMINEDIR"/plugins || exit
ln -s "$BASEDIR" .
cp "$GITPODDIR"/database.yml "$REDMINEDIR"/config/
mkdir "$REDMINEDIR"/.vscode
cd "$REDMINEDIR"/.vscode || exit
ln -s "$GITPODDIR"/launch.json .
echo "gem 'ruby-debug-ide'" >> "$REDMINEDIR"/Gemfile
echo "gem 'debase'" >> "$REDMINEDIR"/Gemfile
sed -i 's/^end$/ config.hosts.clear\nend/' "$REDMINEDIR"/config/environments/development.rb
fi


17 changes: 17 additions & 0 deletions .gitpod/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

REDMINEDIR=/workspace/redmine
cd $(dirname "$0") || exit
GITPODDIR=$(pwd)
cd ..
BASEDIR=$(pwd)
PLUGIN_NAME=$(basename "$BASEDIR")

cd "$REDMINEDIR" || exit
sed "s/__PLUGIN__NAME/$PLUGIN_NAME/" "$GITPODDIR"/gitpod.code-workspace > "$REDMINEDIR"/gitpod.code-workspace
gem install ruby-debug-ide
bundle install --path vendor/bundle
bundle exec rake db:migrate
bundle exec rake redmine:plugins:migrate
bundle exec rake db:migrate RAILS_ENV=test
bundle exec rake redmine:plugins:migrate RAILS_ENV=test
17 changes: 16 additions & 1 deletion app/controllers/wiki_extensions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
class WikiExtensionsController < ApplicationController
unloadable
menu_item :wiki
before_action :find_project, :authorize, :find_user
before_action :find_project, :find_user
before_action :authorize, except: :stylesheet

def add_comment

Expand Down Expand Up @@ -101,6 +102,20 @@ def vote

render :inline => " #{vote.count}"
end

def stylesheet
stylesheet = WikiPage.find_by(wiki_id: @project.wiki.id, title: "StyleSheet")
unless stylesheet
render_404
return
end

unless stylesheet.visible?
render_403
return
end
render plain: stylesheet.content.text, content_type: 'text/css'
end

private
def find_project
Expand Down
4 changes: 1 addition & 3 deletions app/views/wiki_extensions/_html_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
-%>
<% if style_sheet -%>
<style type="text/css">
<%= raw style_sheet.text %>
</style>
<%= stylesheet_link_tag( wiki_extensions_stylesheet_path(@project)) %>
<% end -%>
Expand Down
2 changes: 1 addition & 1 deletion build-scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fi

mkdir -p $TESTSPACE

export REDMINE_GIT_REPO=git://github.com/redmine/redmine.git
export REDMINE_GIT_REPO=https://github.com/redmine/redmine.git
export REDMINE_GIT_TAG=$REDMINE_VER
export BUNDLE_GEMFILE=$PATH_TO_REDMINE/Gemfile

Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

RedmineApp::Application.routes.draw do
match 'projects/:id/wiki_extensions/stylesheet', to: 'wiki_extensions#stylesheet', via: [:get, :post], as: 'wiki_extensions_stylesheet'
match 'projects/:id/wiki_extensions/:action', :controller => 'wiki_extensions', :via => [:get, :post]
match 'projects/:id/wiki_extensions_settings/:action', :controller => 'wiki_extensions_settings', :via => [:get, :post, :put, :patch]
end
2 changes: 1 addition & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
author_url 'http://twitter.com/haru_iida'
description 'This is a Wiki Extensions plugin for Redmine'
url 'http://www.r-labs.org/projects/r-labs/wiki/Wiki_Extensions_en'
version '0.9.3'
version '0.9.4'
requires_redmine :version_or_higher => '4.0.0'

project_module :wiki_extensions do
Expand Down
14 changes: 14 additions & 0 deletions test/functional/wiki_extensions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ def test_forwad_wiki_page
assert_response :redirect
end

def test_stylesheet
@project.is_public = false
@project.save!
get :stylesheet, :params => { :id => 1 }
assert_response 403

@request.session[:user_id] = 1
get :stylesheet, :params => { :id => 1 }
assert_response :success

get :stylesheet, :params => { :id => 2 }
assert_response 404
end

context 'vote' do
should 'success if new vote.' do
@request.session[:user_id] = 1
Expand Down

0 comments on commit 43c6e4c

Please sign in to comment.