redmine_acts_as_taggable_on 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitmodules +3 -0
- data/.travis.yml +4 -0
- data/README.md +46 -16
- data/lib/redmine_acts_as_taggable_on/migration.rb +76 -29
- data/lib/redmine_acts_as_taggable_on/redmine_plugin_patch.rb +6 -0
- data/lib/redmine_acts_as_taggable_on/version.rb +1 -1
- data/redmine_acts_as_taggable_on.gemspec +1 -1
- data/test/mk_temp_redmine.bash +30 -0
- data/test/run.bash +44 -0
- data/test/test.bats +143 -0
- data/test/test_helpers.bash +99 -0
- metadata +24 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af36a6d9277e4b6f7ebb23802fd4df6df58549e2
|
4
|
+
data.tar.gz: 170406c9ce7d640b54d6f0958733c19a788cb8b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80e76b8c0900f2770409953877d088c65555095bdef02dc073c17227b03e94f2ba35f294de25f2330689328c459b910437274dba081b0f7fb3d45c244189779c
|
7
|
+
data.tar.gz: 0400ed073a494d7e57abdbc06029d07bebe198fbad7465f1f446a5dee3a7f8008b29639cfeee0229a3afefb3ed1fe90963d2ea202761dded90cda029a8302b89
|
data/.gitmodules
ADDED
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# redmine_acts_as_taggable_on
|
2
2
|
|
3
3
|
`redmine_acts_as_taggable_on` is a gem which allows multiple Redmine plugins to
|
4
|
-
use the tables provided by `
|
4
|
+
use the tables provided by `acts-as-taggable-on` without stepping on each
|
5
5
|
others' toes.
|
6
6
|
|
7
|
-
##
|
7
|
+
## Why?
|
8
8
|
|
9
9
|
The problem we ran into when we discovered that both `redmine_tags` and
|
10
|
-
`redmine_knowledgebase` want to use the `
|
10
|
+
`redmine_knowledgebase` want to use the `acts-as-taggable-on` gem is that after
|
11
11
|
either is installed, the migration for the other fails, since the database
|
12
12
|
tables already exist.
|
13
13
|
|
@@ -23,30 +23,33 @@ mechanism to declare that they require these tables, and providing intelligent
|
|
23
23
|
migrations which only drop the tables when no other plugins are using them.
|
24
24
|
|
25
25
|
`redmine_acts_as_taggable_on` also provides a limited defence against plugins
|
26
|
-
which directly depend on `acts-as-taggable-on
|
27
|
-
Gemfiles for the string `acts-as-taggable-on
|
28
|
-
|
29
|
-
use this gem instead.
|
26
|
+
which directly depend on `acts-as-taggable-on`. It does this by grepping
|
27
|
+
through their Gemfiles for the string `acts-as-taggable-on` -- if found, it
|
28
|
+
will treat the plugin as requiring the `acts-as-taggable-on` tables, and will
|
29
|
+
print a gentle(-ish) suggestion to use this gem instead.
|
30
30
|
|
31
31
|
## Status
|
32
32
|
|
33
|
-
|
33
|
+
Believed to be stable. The automated tests currently pass on Redmine trunk,
|
34
|
+
2.3.1, 2.2.4, and 2.1.5. However, this gem is not yet used by any Redmine
|
35
|
+
plugins in the wild.
|
34
36
|
|
35
37
|
## Limitations
|
36
38
|
|
37
|
-
This
|
38
|
-
using `acts-as-taggable-on` has put the generated migration into its
|
39
|
-
|
39
|
+
This gem cannot currently protect against situations where a plugin directly
|
40
|
+
using `acts-as-taggable-on` has put the generated migration into its db/migrate
|
41
|
+
directory. If a user tries to migrate the plugin down by executing `rake
|
42
|
+
redmine:plugins:migrate VERSION=0 NAME=redmine_foo_plugin`, the tables will
|
43
|
+
still be dropped, regardless of whether other plugins are still using them.
|
40
44
|
|
41
|
-
I'm in two minds about whether to fix this:
|
42
|
-
some nasty
|
43
|
-
losing one's data is not fun.
|
45
|
+
I'm in two minds about whether to fix this: on the one hand, it would require
|
46
|
+
some nasty monkey-patching. On the other hand, data loss is no fun at all.
|
44
47
|
|
45
48
|
## Setup
|
46
49
|
|
47
50
|
Add it to your plugin's Gemfile:
|
48
51
|
|
49
|
-
gem 'redmine_acts_as_taggable_on', '~> 0.
|
52
|
+
gem 'redmine_acts_as_taggable_on', '~> 0.2'
|
50
53
|
|
51
54
|
Add the migration:
|
52
55
|
|
@@ -61,4 +64,31 @@ Declare that your plugin needs `redmine_acts_as_taggable_on` inside init.rb:
|
|
61
64
|
requires_acts_as_taggable_on
|
62
65
|
...
|
63
66
|
|
64
|
-
That's it. Your plugin
|
67
|
+
That's it. Your plugin will now migrate up and down intelligently. For example:
|
68
|
+
|
69
|
+
cd /path/to/redmine
|
70
|
+
|
71
|
+
cp -r /some/plugin/using/this/gem plugins/redmine_foo
|
72
|
+
cp -r /another/plugin/using/this/gem plugins/redmine_bar
|
73
|
+
|
74
|
+
rake redmine:plugins:migrate
|
75
|
+
|
76
|
+
Migrating redmine_bar (Redmine bar)...
|
77
|
+
== AddTagsAndTaggings: migrating =========================================
|
78
|
+
-- create_table(:tags)
|
79
|
+
-> 0.0039s
|
80
|
+
-- create_table(:taggings)
|
81
|
+
-> 0.0007s
|
82
|
+
-- add_index(:taggings, :tag_id)
|
83
|
+
-> 0.0003s
|
84
|
+
-- add_index(:taggings, [:taggable_id, :taggable_type, :context])
|
85
|
+
-> 0.0003s
|
86
|
+
== AddTagsAndTaggings: migrated (0.0059s) ================================
|
87
|
+
|
88
|
+
Migrating redmine_foo (Redmine foo)...
|
89
|
+
== AddTagsAndTaggings: migrating =========================================
|
90
|
+
-- Not creating "tags" and "taggings" because they already exist
|
91
|
+
== AddTagsAndTaggings: migrated (0.0006s) ================================
|
92
|
+
|
93
|
+
You can look at the [test script](test/test.bats) to see how other situations
|
94
|
+
are handled.
|
@@ -1,13 +1,16 @@
|
|
1
1
|
require 'generators/acts_as_taggable_on/migration/templates/active_record/migration'
|
2
2
|
|
3
3
|
class RedmineActsAsTaggableOn::Migration < ActsAsTaggableOnMigration
|
4
|
+
class SchemaMismatchError < StandardError; end
|
5
|
+
|
4
6
|
def up
|
5
7
|
enforce_declarations!
|
8
|
+
check_for_old_style_plugins
|
6
9
|
|
7
|
-
if
|
8
|
-
say 'Not creating "tags" and "taggings" because they already exist'
|
9
|
-
else
|
10
|
+
if ok_to_go_up?
|
10
11
|
super
|
12
|
+
else
|
13
|
+
say 'Not creating "tags" and "taggings" because they already exist'
|
11
14
|
end
|
12
15
|
end
|
13
16
|
|
@@ -19,35 +22,11 @@ class RedmineActsAsTaggableOn::Migration < ActsAsTaggableOnMigration
|
|
19
22
|
else
|
20
23
|
say 'Not dropping "tags" and "taggings" because they\'re still needed by'
|
21
24
|
say 'the following plugins:'
|
22
|
-
|
25
|
+
plugins_still_using_tables.each { |p| say p.id, true }
|
23
26
|
end
|
24
27
|
end
|
25
28
|
|
26
29
|
private
|
27
|
-
def performed?
|
28
|
-
['tags', 'taggings'].any? do |table|
|
29
|
-
ActiveRecord::Base.connection.table_exists? table
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# A list of plugins which require redmine_acts_as_taggable_on.
|
34
|
-
#
|
35
|
-
# We reject the current one because we don't want to say
|
36
|
-
#
|
37
|
-
# refusing to migrate redmine_foo down: tags and taggings tables are still
|
38
|
-
# required by redmine_foo
|
39
|
-
#
|
40
|
-
# That would be silly.
|
41
|
-
def requiring_plugins
|
42
|
-
Redmine::Plugin.all.
|
43
|
-
select(&:requires_acts_as_taggable_on?).
|
44
|
-
reject {|p| p == Redmine::Plugin::Migrator.current_plugin }
|
45
|
-
end
|
46
|
-
|
47
|
-
def ok_to_go_down?
|
48
|
-
requiring_plugins.empty?
|
49
|
-
end
|
50
|
-
|
51
30
|
def enforce_declarations!
|
52
31
|
unless current_plugin_declaration_made?
|
53
32
|
msg = "You have to declare that you need redmine_acts_as_taggable_on inside\n"
|
@@ -58,6 +37,74 @@ class RedmineActsAsTaggableOn::Migration < ActsAsTaggableOnMigration
|
|
58
37
|
end
|
59
38
|
|
60
39
|
def current_plugin_declaration_made?
|
61
|
-
|
40
|
+
current_plugin.requires_acts_as_taggable_on?
|
41
|
+
end
|
42
|
+
|
43
|
+
def current_plugin
|
44
|
+
Redmine::Plugin::Migrator.current_plugin
|
45
|
+
end
|
46
|
+
|
47
|
+
# Check if any plugins are using acts-as-taggable-on directly; the purpose of
|
48
|
+
# this is only to print a warning if so.
|
49
|
+
def check_for_old_style_plugins
|
50
|
+
Redmine::Plugin.all.each { |p| p.requires_acts_as_taggable_on? }
|
51
|
+
nil
|
52
|
+
end
|
53
|
+
|
54
|
+
def ok_to_go_up?
|
55
|
+
tables_already_exist = %w(tags taggings).any? do |table|
|
56
|
+
ActiveRecord::Base.connection.table_exists? table
|
57
|
+
end
|
58
|
+
if tables_already_exist
|
59
|
+
assert_schema_match!
|
60
|
+
return false
|
61
|
+
end
|
62
|
+
true
|
63
|
+
end
|
64
|
+
|
65
|
+
def assert_schema_match!
|
66
|
+
if (obtain_structure('tags') != expected_tags_structure) ||
|
67
|
+
(obtain_structure('taggings') != expected_taggings_structure)
|
68
|
+
msg = "A plugin is already using the \"tags\" or \"taggings\" tables, and\n"
|
69
|
+
msg << "the structure of the table does not match the structure expected\n"
|
70
|
+
msg << "by #{current_plugin.id}.\n"
|
71
|
+
raise SchemaMismatchError, msg
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def obtain_structure(table_name)
|
76
|
+
ActiveRecord::Base.connection.columns(table_name).
|
77
|
+
reject { |c| %w(created_at updated_at id).include? c.name }.
|
78
|
+
map { |c| [c.name, c.type.to_s] }.
|
79
|
+
sort
|
80
|
+
end
|
81
|
+
|
82
|
+
def expected_tags_structure
|
83
|
+
[
|
84
|
+
['name', 'string']
|
85
|
+
]
|
86
|
+
end
|
87
|
+
|
88
|
+
def expected_taggings_structure
|
89
|
+
[
|
90
|
+
['tag_id', 'integer'],
|
91
|
+
['taggable_id', 'integer'],
|
92
|
+
['taggable_type', 'string'],
|
93
|
+
['tagger_id', 'integer'],
|
94
|
+
['tagger_type', 'string'],
|
95
|
+
['context', 'string'],
|
96
|
+
].sort
|
97
|
+
end
|
98
|
+
|
99
|
+
# A list of plugins which are using the acts_as_taggable_on tables (excluding
|
100
|
+
# the current one)
|
101
|
+
def plugins_still_using_tables
|
102
|
+
Redmine::Plugin.all.
|
103
|
+
select(&:using_acts_as_taggable_on_tables?).
|
104
|
+
reject {|p| p == Redmine::Plugin::Migrator.current_plugin }
|
105
|
+
end
|
106
|
+
|
107
|
+
def ok_to_go_down?
|
108
|
+
plugins_still_using_tables.empty?
|
62
109
|
end
|
63
110
|
end
|
@@ -18,6 +18,12 @@ module RedmineActsAsTaggableOn::RedminePluginPatch
|
|
18
18
|
false
|
19
19
|
end
|
20
20
|
|
21
|
+
def using_acts_as_taggable_on_tables?
|
22
|
+
return false unless requires_acts_as_taggable_on?
|
23
|
+
return false if Redmine::Plugin::Migrator.current_version(self) == 0
|
24
|
+
true
|
25
|
+
end
|
26
|
+
|
21
27
|
private
|
22
28
|
def gemfile_path
|
23
29
|
File.join(self.directory, 'Gemfile')
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency "acts-as-taggable-on", "
|
21
|
+
spec.add_runtime_dependency "acts-as-taggable-on", ">= 2.3", "< 2.5"
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
24
24
|
spec.add_development_dependency "rake"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -e
|
3
|
+
|
4
|
+
# makes a new Redmine installation in a temporary directory, using SQLite as
|
5
|
+
# the database.
|
6
|
+
make_temp_redmine() {
|
7
|
+
local branch="$1"
|
8
|
+
[ -z "$branch" ] && branch="trunk"
|
9
|
+
|
10
|
+
# for branches which have slashes in them, like tags/2.3.0
|
11
|
+
local branch_filename="${branch//\//-}"
|
12
|
+
temp_redmine=`mktemp -d /tmp/redmine_acts_as_taggable_on.$branch_filename.XXXXXXX`
|
13
|
+
pushd "$temp_redmine"
|
14
|
+
|
15
|
+
svn checkout "http://svn.redmine.org/redmine/$branch" redmine
|
16
|
+
pushd redmine
|
17
|
+
|
18
|
+
echo "production:
|
19
|
+
adapter: sqlite3
|
20
|
+
database: db/redmine.sqlite3" > config/database.yml
|
21
|
+
|
22
|
+
bundle install
|
23
|
+
rake generate_secret_token db:create db:migrate
|
24
|
+
|
25
|
+
popd
|
26
|
+
popd
|
27
|
+
}
|
28
|
+
|
29
|
+
make_temp_redmine >/dev/null
|
30
|
+
echo "$temp_redmine"
|
data/test/run.bash
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -e
|
3
|
+
|
4
|
+
# Run all the tests on a specific branch of Redmine.
|
5
|
+
run_tests_on_branch() {
|
6
|
+
temp_redmine_path="`test/mk_temp_redmine.bash "$1"`"
|
7
|
+
export temp_redmine_path
|
8
|
+
|
9
|
+
[ -f test/bats/bin/bats ] || git submodule update
|
10
|
+
|
11
|
+
local test_status=0
|
12
|
+
test/bats/bin/bats test/test.bats || test_status=1
|
13
|
+
|
14
|
+
if [ "$test_status" -eq 1 ]; then
|
15
|
+
echo "Some tests failed on redmine:$1. You can inspect the tree at $temp_redmine_path"
|
16
|
+
else
|
17
|
+
rm -rf "$temp_redmine_path"
|
18
|
+
fi
|
19
|
+
|
20
|
+
return $test_status
|
21
|
+
}
|
22
|
+
|
23
|
+
RAILS_ENV="production"
|
24
|
+
export RAILS_ENV
|
25
|
+
|
26
|
+
redmine_acts_as_taggable_on_path="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)"
|
27
|
+
export redmine_acts_as_taggable_on_path
|
28
|
+
pushd "$redmine_acts_as_taggable_on_path" >/dev/null
|
29
|
+
|
30
|
+
branches=(trunk tags/2.3.1 tags/2.2.4 tags/2.1.5)
|
31
|
+
test_status=0
|
32
|
+
|
33
|
+
for branch in ${branches[@]}; do
|
34
|
+
echo "testing on branch: $branch"
|
35
|
+
echo -n "==================="
|
36
|
+
# make the underline the same length as the title
|
37
|
+
echo ${branch//?/=}
|
38
|
+
|
39
|
+
run_tests_on_branch "$branch" || test_status=1
|
40
|
+
echo
|
41
|
+
done
|
42
|
+
|
43
|
+
popd >/dev/null
|
44
|
+
exit $test_status
|
data/test/test.bats
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
#!/usr/bin/env bats
|
2
|
+
|
3
|
+
load test_helpers
|
4
|
+
|
5
|
+
# files which should be backed up and restored to how they were at the start
|
6
|
+
# between each test
|
7
|
+
preserved_files=(db/redmine.sqlite3 db/schema.rb)
|
8
|
+
|
9
|
+
setup() {
|
10
|
+
pushd "$temp_redmine_path/redmine" >/dev/null
|
11
|
+
for file in $preserved_files; do
|
12
|
+
cp $file $file.bak
|
13
|
+
done
|
14
|
+
}
|
15
|
+
|
16
|
+
teardown() {
|
17
|
+
rm -rf plugins/*
|
18
|
+
for file in $preserved_files; do
|
19
|
+
mv $file.bak $file
|
20
|
+
done
|
21
|
+
popd >/dev/null
|
22
|
+
}
|
23
|
+
|
24
|
+
@test "migrates upwards with solitary proper plugin" {
|
25
|
+
mk_proper_plugin "foo"
|
26
|
+
rake redmine:plugins:migrate
|
27
|
+
|
28
|
+
db_table_exists 'tags'
|
29
|
+
db_table_exists 'taggings'
|
30
|
+
}
|
31
|
+
|
32
|
+
@test "migrates downwards with solitary proper plugin" {
|
33
|
+
mk_proper_plugin "foo"
|
34
|
+
rake redmine:plugins:migrate
|
35
|
+
rake redmine:plugins:migrate NAME=redmine_foo VERSION=0
|
36
|
+
|
37
|
+
! db_table_exists 'tags'
|
38
|
+
! db_table_exists 'taggings'
|
39
|
+
}
|
40
|
+
|
41
|
+
@test "migrates upwards with two proper plugins" {
|
42
|
+
mk_proper_plugin "foo"
|
43
|
+
rake redmine:plugins:migrate
|
44
|
+
|
45
|
+
mk_proper_plugin "bar"
|
46
|
+
run rake redmine:plugins:migrate
|
47
|
+
[ "$status" -eq 0 ]
|
48
|
+
assert_contain 'Not creating "tags" and "taggings"' "$output"
|
49
|
+
|
50
|
+
db_table_exists 'tags'
|
51
|
+
db_table_exists 'taggings'
|
52
|
+
}
|
53
|
+
|
54
|
+
@test "doesn't drop tables when another proper plugin exists" {
|
55
|
+
mk_proper_plugin "foo"
|
56
|
+
mk_proper_plugin "bar"
|
57
|
+
|
58
|
+
rake redmine:plugins:migrate
|
59
|
+
|
60
|
+
echo 'Now migrating down...'
|
61
|
+
run rake redmine:plugins:migrate NAME=redmine_foo VERSION=0
|
62
|
+
[ "$status" -eq 0 ]
|
63
|
+
assert_contain 'Not dropping "tags" and "taggings"' "$output"
|
64
|
+
|
65
|
+
# Should say still needed by redmine_bar
|
66
|
+
assert_contain '-> redmine_bar' "$output"
|
67
|
+
# Should not say still needed by redmine_foo
|
68
|
+
! assert_contain '-> redmine_foo' "$output"
|
69
|
+
|
70
|
+
db_table_exists 'tags'
|
71
|
+
db_table_exists 'taggings'
|
72
|
+
}
|
73
|
+
|
74
|
+
@test "migrates downwards with two proper plugins" {
|
75
|
+
mk_proper_plugin "foo"
|
76
|
+
mk_proper_plugin "bar"
|
77
|
+
|
78
|
+
rake redmine:plugins:migrate
|
79
|
+
rake redmine:plugins:migrate NAME=redmine_foo VERSION=0
|
80
|
+
rake redmine:plugins:migrate NAME=redmine_bar VERSION=0
|
81
|
+
|
82
|
+
! db_table_exists 'tags'
|
83
|
+
! db_table_exists 'taggings'
|
84
|
+
}
|
85
|
+
|
86
|
+
@test "schema sanity check when migrating proper plugin up" {
|
87
|
+
mk_standard_plugin "baz"
|
88
|
+
|
89
|
+
mkdir -p plugins/redmine_baz/db/migrate
|
90
|
+
echo "class AddTags < ActiveRecord::Migration
|
91
|
+
def up
|
92
|
+
create_table :tags do |t|
|
93
|
+
t.integer :foo
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def down
|
98
|
+
drop_table :tags
|
99
|
+
end
|
100
|
+
end" > plugins/redmine_baz/db/migrate/001_add_tags.rb
|
101
|
+
|
102
|
+
rake redmine:plugins:migrate
|
103
|
+
|
104
|
+
mk_proper_plugin "foo"
|
105
|
+
run rake redmine:plugins:migrate
|
106
|
+
[ "$status" -ne 0 ]
|
107
|
+
assert_contain 'table does not match' "$output"
|
108
|
+
}
|
109
|
+
|
110
|
+
@test "enforces that declarations were made" {
|
111
|
+
mk_plugin_missing_declaration "quux"
|
112
|
+
|
113
|
+
run rake redmine:plugins:migrate
|
114
|
+
[ "$status" -ne 0 ]
|
115
|
+
echo "$output"
|
116
|
+
assert_contain 'You have to declare that you need' "$output"
|
117
|
+
}
|
118
|
+
|
119
|
+
@test "warns about acts-as-taggable-on when going up" {
|
120
|
+
mk_proper_plugin "foo"
|
121
|
+
mk_old_style_plugin "bar"
|
122
|
+
|
123
|
+
run rake redmine:plugins:migrate
|
124
|
+
[ "$status" -eq 0 ]
|
125
|
+
echo "$output"
|
126
|
+
assert_contain "WARNING: The plugin redmine_bar is using 'acts-" "$output"
|
127
|
+
}
|
128
|
+
|
129
|
+
@test "warns about acts-as-taggable-on when going down" {
|
130
|
+
mk_proper_plugin "foo"
|
131
|
+
mk_old_style_plugin "bar"
|
132
|
+
|
133
|
+
rake redmine:plugins:migrate
|
134
|
+
|
135
|
+
# Note that we have to migrate redmine_foo down so that the
|
136
|
+
# RedmineActsAsTaggableOn::Migration class does the migration, because it
|
137
|
+
# does the checking. Migrating redmine_bar down would not trigger the
|
138
|
+
# warning.
|
139
|
+
run rake redmine:plugins:migrate NAME=redmine_foo VERSION=0
|
140
|
+
[ "$status" -eq 0 ]
|
141
|
+
echo "$output"
|
142
|
+
assert_contain "WARNING: The plugin redmine_bar is using 'acts-" "$output"
|
143
|
+
}
|
@@ -0,0 +1,99 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# Create an empty skeleton Redmine plugin. It's given the name redmine_$1.
|
4
|
+
mk_standard_plugin() {
|
5
|
+
local name="redmine_$1"
|
6
|
+
mkdir plugins/$name
|
7
|
+
pushd plugins/$name >/dev/null
|
8
|
+
|
9
|
+
echo "Redmine::Plugin.register(:$name) { name '$name' }" > init.rb
|
10
|
+
|
11
|
+
popd >/dev/null
|
12
|
+
|
13
|
+
echo "Created a standard redmine plugin: $name"
|
14
|
+
}
|
15
|
+
|
16
|
+
# Create a plugin which uses the redmine_acts_as_taggable_on gem properly.
|
17
|
+
mk_proper_plugin() {
|
18
|
+
mk_standard_plugin "$1" >/dev/null
|
19
|
+
local name="redmine_$1"
|
20
|
+
pushd plugins/$name >/dev/null
|
21
|
+
|
22
|
+
echo "gem 'redmine_acts_as_taggable_on',
|
23
|
+
:path => '$redmine_acts_as_taggable_on_path'" > Gemfile
|
24
|
+
|
25
|
+
echo "require 'redmine_acts_as_taggable_on/initialize'
|
26
|
+
Redmine::Plugin.register(:$name) { requires_acts_as_taggable_on }" \
|
27
|
+
> init.rb
|
28
|
+
|
29
|
+
mkdir -p db/migrate
|
30
|
+
echo "class AddTagsAndTaggings < RedmineActsAsTaggableOn::Migration; end" \
|
31
|
+
> db/migrate/001_add_tags_and_taggings.rb
|
32
|
+
|
33
|
+
bundle >/dev/null
|
34
|
+
|
35
|
+
popd >/dev/null
|
36
|
+
|
37
|
+
echo "Created a redmine plugin using redmine_acts_as_taggable_on: $name"
|
38
|
+
}
|
39
|
+
|
40
|
+
# Create a plugin which uses redmine_acts_as_taggable_on but without the
|
41
|
+
# declaration in init.rb
|
42
|
+
mk_plugin_missing_declaration() {
|
43
|
+
mk_proper_plugin "$1" >/dev/null
|
44
|
+
local name="redmine_$1"
|
45
|
+
pushd plugins/$name >/dev/null
|
46
|
+
|
47
|
+
echo "require 'redmine_acts_as_taggable_on/initialize'
|
48
|
+
Redmine::Plugin.register(:$name) { name '$name' }" > init.rb
|
49
|
+
|
50
|
+
popd >/dev/null
|
51
|
+
|
52
|
+
echo "Created a redmine plugin using redmine_acts_as_taggable_on"
|
53
|
+
echo " (but without the declaration): $name"
|
54
|
+
}
|
55
|
+
|
56
|
+
# Create a plugin which uses acts-as-taggable-on directly, and which expects
|
57
|
+
# you to do rails g acts_as_taggable_on:migration yourself.
|
58
|
+
mk_old_style_plugin() {
|
59
|
+
mk_standard_plugin "$1" >/dev/null
|
60
|
+
local name="redmine_$1"
|
61
|
+
pushd plugins/$name >/dev/null
|
62
|
+
|
63
|
+
echo "gem 'acts-as-taggable-on'" > Gemfile
|
64
|
+
bundle >/dev/null
|
65
|
+
popd >/dev/null
|
66
|
+
|
67
|
+
echo "Created a plugin using acts-as-taggable-on without the embedded"
|
68
|
+
echo " migration: $name"
|
69
|
+
}
|
70
|
+
|
71
|
+
db_query() {
|
72
|
+
# use -init to ensure ~/.sqliterc isn't read
|
73
|
+
sqlite3 -init "" db/redmine.sqlite3 "$1"
|
74
|
+
}
|
75
|
+
|
76
|
+
db_table_exists() {
|
77
|
+
db_query "SELECT 'it exists'
|
78
|
+
FROM sqlite_master
|
79
|
+
WHERE type='table' AND name='$1'" | grep 'it exists' >/dev/null
|
80
|
+
|
81
|
+
exists="$?"
|
82
|
+
if [ "$exists" -eq 1 ]; then
|
83
|
+
echo "Database table $1 exists."
|
84
|
+
else
|
85
|
+
echo "Database table $1 does not exist."
|
86
|
+
fi
|
87
|
+
|
88
|
+
return $exists
|
89
|
+
}
|
90
|
+
|
91
|
+
assert_contain() {
|
92
|
+
echo -n "Checking whether a string contains '$1'... "
|
93
|
+
if [[ "$2" == *"$1"* ]]; then
|
94
|
+
echo "Yep."
|
95
|
+
else
|
96
|
+
echo "Nope."
|
97
|
+
return 1
|
98
|
+
fi
|
99
|
+
}
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redmine_acts_as_taggable_on
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harry Garrood
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: acts-as-taggable-on
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.3'
|
20
|
+
- - <
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
22
|
+
version: '2.5'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.3'
|
30
|
+
- - <
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
32
|
+
version: '2.5'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: bundler
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,6 +66,8 @@ extensions: []
|
|
60
66
|
extra_rdoc_files: []
|
61
67
|
files:
|
62
68
|
- .gitignore
|
69
|
+
- .gitmodules
|
70
|
+
- .travis.yml
|
63
71
|
- Gemfile
|
64
72
|
- LICENSE.txt
|
65
73
|
- README.md
|
@@ -70,6 +78,10 @@ files:
|
|
70
78
|
- lib/redmine_acts_as_taggable_on/redmine_plugin_patch.rb
|
71
79
|
- lib/redmine_acts_as_taggable_on/version.rb
|
72
80
|
- redmine_acts_as_taggable_on.gemspec
|
81
|
+
- test/mk_temp_redmine.bash
|
82
|
+
- test/run.bash
|
83
|
+
- test/test.bats
|
84
|
+
- test/test_helpers.bash
|
73
85
|
homepage: https://github.com/hdgarrood/redmine_acts_as_taggable_on
|
74
86
|
licenses:
|
75
87
|
- GPLv2
|
@@ -90,10 +102,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
102
|
version: '0'
|
91
103
|
requirements: []
|
92
104
|
rubyforge_project:
|
93
|
-
rubygems_version: 2.0.
|
105
|
+
rubygems_version: 2.0.3
|
94
106
|
signing_key:
|
95
107
|
specification_version: 4
|
96
108
|
summary: Allows multiple Redmine plugins to use the acts_as_taggable_on gem without
|
97
109
|
stepping on each others' toes.
|
98
|
-
test_files:
|
110
|
+
test_files:
|
111
|
+
- test/mk_temp_redmine.bash
|
112
|
+
- test/run.bash
|
113
|
+
- test/test.bats
|
114
|
+
- test/test_helpers.bash
|
99
115
|
has_rdoc:
|