Skip to content

Commit

Permalink
Add test against plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
hidakatsuya committed May 18, 2024
1 parent f2cca19 commit 4ae6f09
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/hello_world/README.rdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
= hello_world

Description goes here
2 changes: 2 additions & 0 deletions .github/hello_world/app/models/hello.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Hello < ApplicationRecord
end
3 changes: 3 additions & 0 deletions .github/hello_world/config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# English strings go here for Rails i18n
en:
# my_label: "My label"
2 changes: 2 additions & 0 deletions .github/hello_world/config/routes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Plugin's routes
# See: http://guides.rubyonrails.org/routing.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class CreateHellos < ActiveRecord::Migration[7.1]
def change
create_table :hellos do |t|
t.string :world
end
end
end
8 changes: 8 additions & 0 deletions .github/hello_world/init.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Redmine::Plugin.register :hello_world do
name 'Hello World'
author 'Author name'
description 'This is a plugin for Redmine'
version '0.0.1'
url 'http://example.com/path/to/plugin'
author_url 'http://example.com/about'
end
2 changes: 2 additions & 0 deletions .github/hello_world/test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Load the Redmine helper
require_relative '../../../test/test_helper'
8 changes: 8 additions & 0 deletions .github/hello_world/test/unit/hello_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require_relative '../test_helper'

class HelloTest < ActiveSupport::TestCase
def test_world
Hello.create world: "Redmine"
assert_equal "Redmine", Hello.first.world
end
end
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,22 @@ jobs:
database: ${{ matrix.redmine-database }}
ruby-version: ${{ matrix.ruby-version }}

- name: Install a plugin for testing
run: |
cp -R ../.github/hello_world plugins/
bin/rails redmine:plugins:migrate
working-directory: ${{ env.REDMINE_SRC }}

- run: |
about=$(bin/rails r "require 'redmine/version'; puts Redmine::Info.environment")
echo "$about"
echo "$about" | grep "${{ matrix.expected-about-db-adapter }}"
echo "$about" | grep "${{ matrix.expected-about-redmine-version }}"
echo "$about" | grep "Hello World"
working-directory: ${{ env.REDMINE_SRC }}
- run: |
bin/rails test test/unit/news_test.rb
bin/rails test test/system/my_page_test.rb
bin/rails redmine:plugins:test
working-directory: ${{ env.REDMINE_SRC }}

0 comments on commit 4ae6f09

Please sign in to comment.