Skip to content

Commit 50d9b98

Browse files
authored
Merge pull request #174 from gtt-project/fix/create-and-continue
Fix "gtt_tile_sources" view's "create_and_continue" button action (#173)
2 parents d749d51 + 566fc21 commit 50d9b98

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

app/controllers/gtt_tile_sources_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def new
1616
def create
1717
r = RedmineGtt::Actions::CreateTileSource.(tile_source_params)
1818
if r.tile_source_created?
19-
redirect_to gtt_tile_sources_path
19+
redirect_to(params[:continue] ? new_gtt_tile_source_path : gtt_tile_sources_path)
2020
else
2121
@tile_source = r.tile_source
2222
render 'new'

test/functional/gtt_tile_sources_controller_test.rb

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,41 @@ class GttTileSourcesControllerTest < ActionController::TestCase
3030

3131
test 'should create tile source' do
3232
assert_difference 'GttTileSource.count' do
33-
post :create, params: { tile_source: {
34-
name: 'test',
35-
type: 'GttOsmTileSource',
36-
options_string: {
37-
attributions: 'test',
38-
url: 'https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png'
39-
}.to_json
40-
}}
33+
post :create, params: {
34+
tile_source: {
35+
name: 'test',
36+
type: 'GttOsmTileSource',
37+
options_string: {
38+
attributions: 'test',
39+
url: 'https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png'
40+
}.to_json
41+
}
42+
}
4143
end
4244

45+
assert_redirected_to '/gtt_tile_sources'
46+
assert ts = GttTileSource.last
47+
assert_equal 'test', ts.options['attributions']
48+
assert_equal 'https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png',
49+
ts.options['url']
50+
end
51+
52+
test 'should create tile source and continue' do
53+
assert_difference 'GttTileSource.count' do
54+
post :create, params: {
55+
tile_source: {
56+
name: 'test',
57+
type: 'GttOsmTileSource',
58+
options_string: {
59+
attributions: 'test',
60+
url: 'https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png'
61+
}.to_json
62+
},
63+
continue: 'Create and continue'
64+
}
65+
end
66+
67+
assert_redirected_to '/gtt_tile_sources/new'
4368
assert ts = GttTileSource.last
4469
assert_equal 'test', ts.options['attributions']
4570
assert_equal 'https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png',

0 commit comments

Comments
 (0)