Commit 7f3a7e5e9febd5971f85ecf8598c43d9f0509b64
Committed by
Paulo Meireles
1 parent
feee81ec
Exists in
master
and in
29 other branches
[Mezuro] Refactored redirects in controllers.
Showing
14 changed files
with
76 additions
and
43 deletions
Show diff stats
plugins/mezuro/controllers/myprofile/mezuro_plugin_metric_configuration_controller.rb
@@ -15,13 +15,13 @@ class MezuroPluginMetricConfigurationController < MezuroPluginMyprofileControlle | @@ -15,13 +15,13 @@ class MezuroPluginMetricConfigurationController < MezuroPluginMyprofileControlle | ||
15 | end | 15 | end |
16 | 16 | ||
17 | def create_native | 17 | def create_native |
18 | + configuration_content = profile.articles.find(params[:id]) | ||
18 | metric_configuration = Kalibro::MetricConfiguration.create(params[:metric_configuration]) | 19 | metric_configuration = Kalibro::MetricConfiguration.create(params[:metric_configuration]) |
19 | 20 | ||
20 | if metric_configuration_has_errors? metric_configuration | 21 | if metric_configuration_has_errors? metric_configuration |
21 | redirect_to_error_page metric_configuration.errors[0].message | 22 | redirect_to_error_page metric_configuration.errors[0].message |
22 | else | 23 | else |
23 | - id = params[:id] | ||
24 | - redirect_to "/myprofile/#{profile.identifier}/plugin/mezuro/metric_configuration/edit_native?id=#{id}&metric_configuration_id=#{metric_configuration.id}" | 24 | + redirect_to(metric_configuration_url(configuration_content)) |
25 | end | 25 | end |
26 | end | 26 | end |
27 | 27 | ||
@@ -42,7 +42,7 @@ class MezuroPluginMetricConfigurationController < MezuroPluginMyprofileControlle | @@ -42,7 +42,7 @@ class MezuroPluginMetricConfigurationController < MezuroPluginMyprofileControlle | ||
42 | if metric_configuration_has_errors? metric_configuration | 42 | if metric_configuration_has_errors? metric_configuration |
43 | redirect_to_error_page metric_configuration.errors[0].message | 43 | redirect_to_error_page metric_configuration.errors[0].message |
44 | else | 44 | else |
45 | - redirect_to "/#{profile.identifier}/#{@configuration_content.slug}" | 45 | + redirect_to @configuration_content.view_url |
46 | end | 46 | end |
47 | end | 47 | end |
48 | 48 | ||
@@ -54,7 +54,7 @@ class MezuroPluginMetricConfigurationController < MezuroPluginMyprofileControlle | @@ -54,7 +54,7 @@ class MezuroPluginMetricConfigurationController < MezuroPluginMyprofileControlle | ||
54 | if metric_configuration_has_errors? metric_configuration | 54 | if metric_configuration_has_errors? metric_configuration |
55 | redirect_to_error_page metric_configuration.errors[0].message | 55 | redirect_to_error_page metric_configuration.errors[0].message |
56 | else | 56 | else |
57 | - redirect_to "/#{profile.identifier}/#{configuration_content.slug}" | 57 | + redirect_to configuration_content.view_url |
58 | end | 58 | end |
59 | end | 59 | end |
60 | 60 | ||
@@ -68,13 +68,13 @@ class MezuroPluginMetricConfigurationController < MezuroPluginMyprofileControlle | @@ -68,13 +68,13 @@ class MezuroPluginMetricConfigurationController < MezuroPluginMyprofileControlle | ||
68 | end | 68 | end |
69 | 69 | ||
70 | def create_compound | 70 | def create_compound |
71 | + configuration_content = profile.articles.find(params[:id]) | ||
71 | metric_configuration = Kalibro::MetricConfiguration.create(params[:metric_configuration]) | 72 | metric_configuration = Kalibro::MetricConfiguration.create(params[:metric_configuration]) |
72 | 73 | ||
73 | if metric_configuration_has_errors? metric_configuration | 74 | if metric_configuration_has_errors? metric_configuration |
74 | redirect_to_error_page metric_configuration.errors[0].message | 75 | redirect_to_error_page metric_configuration.errors[0].message |
75 | else | 76 | else |
76 | - id = params[:id] | ||
77 | - redirect_to "/myprofile/#{profile.identifier}/plugin/mezuro/metric_configuration/edit_compound?id=#{id}&metric_configuration_id=#{metric_configuration.id}" | 77 | + redirect_to(metric_configuration_url(configuration_content)) |
78 | end | 78 | end |
79 | end | 79 | end |
80 | 80 | ||
@@ -105,4 +105,14 @@ class MezuroPluginMetricConfigurationController < MezuroPluginMyprofileControlle | @@ -105,4 +105,14 @@ class MezuroPluginMetricConfigurationController < MezuroPluginMyprofileControlle | ||
105 | def configuration_content_has_errors? | 105 | def configuration_content_has_errors? |
106 | not @configuration_content.errors[:base].nil? | 106 | not @configuration_content.errors[:base].nil? |
107 | end | 107 | end |
108 | + | ||
109 | + def metric_configuration_url configuration_content | ||
110 | + url = configuration_content.view_url | ||
111 | + url[:controller] = controller_name | ||
112 | + url[:id] = configuration_content.id | ||
113 | + url[:metric_configuration_id] = params[:metric_configuration][:id].to_i | ||
114 | + url[:action] = (params[:metric_configuration][:metric][:compound] ? "edit_compound" : "edit_native") | ||
115 | + url | ||
116 | + end | ||
108 | end | 117 | end |
118 | + |
plugins/mezuro/controllers/myprofile/mezuro_plugin_range_controller.rb
@@ -6,6 +6,8 @@ class MezuroPluginRangeController < MezuroPluginMyprofileController | @@ -6,6 +6,8 @@ class MezuroPluginRangeController < MezuroPluginMyprofileController | ||
6 | @content_id = params[:id].to_i | 6 | @content_id = params[:id].to_i |
7 | @metric_configuration_id = params[:metric_configuration_id].to_i | 7 | @metric_configuration_id = params[:metric_configuration_id].to_i |
8 | @reading_labels_and_ids = reading_labels_and_ids | 8 | @reading_labels_and_ids = reading_labels_and_ids |
9 | + @reading_group_id = params[:reading_group_id].to_i | ||
10 | + @compound = params[:compound] | ||
9 | end | 11 | end |
10 | 12 | ||
11 | def edit | 13 | def edit |
@@ -18,6 +20,8 @@ class MezuroPluginRangeController < MezuroPluginMyprofileController | @@ -18,6 +20,8 @@ class MezuroPluginRangeController < MezuroPluginMyprofileController | ||
18 | 20 | ||
19 | def create | 21 | def create |
20 | metric_configuration_id = params[:metric_configuration_id].to_i | 22 | metric_configuration_id = params[:metric_configuration_id].to_i |
23 | + @reading_group_id = params[:reading_group_id].to_i | ||
24 | + @compound = params[:compound] | ||
21 | @range = Kalibro::Range.new params[:range] | 25 | @range = Kalibro::Range.new params[:range] |
22 | @range.save metric_configuration_id | 26 | @range.save metric_configuration_id |
23 | if !@range.errors.empty? | 27 | if !@range.errors.empty? |
@@ -35,19 +39,23 @@ class MezuroPluginRangeController < MezuroPluginMyprofileController | @@ -35,19 +39,23 @@ class MezuroPluginRangeController < MezuroPluginMyprofileController | ||
35 | end | 39 | end |
36 | 40 | ||
37 | def remove | 41 | def remove |
38 | - configuration_content_id = params[:id].to_i | ||
39 | - metric_configuration_id = params[:metric_configuration_id].to_i | ||
40 | - compound = params[:compound] | 42 | + configuration_content = profile.articles.find(params[:id]) |
43 | + | ||
41 | Kalibro::Range.new({:id => params[:range_id].to_i}).destroy | 44 | Kalibro::Range.new({:id => params[:range_id].to_i}).destroy |
42 | - if compound | ||
43 | - redirect_to "/myprofile/#{profile.identifier}/plugin/mezuro/metric_configuration/edit_compound?id=#{configuration_content_id}&metric_configuration_id=#{metric_configuration_id}" | ||
44 | - else | ||
45 | - redirect_to "/myprofile/#{profile.identifier}/plugin/mezuro/metric_configuration/edit_native?id=#{configuration_content_id}&metric_configuration_id=#{metric_configuration_id}" | ||
46 | - end | 45 | + redirect_to(metric_configuration_url(configuration_content)) |
47 | end | 46 | end |
48 | 47 | ||
49 | private | 48 | private |
50 | 49 | ||
50 | + def metric_configuration_url configuration_content | ||
51 | + url = configuration_content.view_url | ||
52 | + url[:controller] = "mezuro_plugin_metric_configuration" | ||
53 | + url[:id] = configuration_content.id | ||
54 | + url[:metric_configuration_id] = params[:metric_configuration_id].to_i | ||
55 | + url[:action] = (params[:compound] ? "edit_compound" : "edit_native") | ||
56 | + url | ||
57 | + end | ||
58 | + | ||
51 | def reading_labels_and_ids | 59 | def reading_labels_and_ids |
52 | array = Kalibro::Reading.readings_of(params[:reading_group_id].to_i).map { |reading| [reading.label, reading.id] } | 60 | array = Kalibro::Reading.readings_of(params[:reading_group_id].to_i).map { |reading| [reading.label, reading.id] } |
53 | array.sort { |x,y| x.first.downcase <=> y.first.downcase } | 61 | array.sort { |x,y| x.first.downcase <=> y.first.downcase } |
plugins/mezuro/controllers/myprofile/mezuro_plugin_reading_controller.rb
@@ -11,11 +11,10 @@ class MezuroPluginReadingController < MezuroPluginMyprofileController | @@ -11,11 +11,10 @@ class MezuroPluginReadingController < MezuroPluginMyprofileController | ||
11 | 11 | ||
12 | def create | 12 | def create |
13 | reading_group_content = profile.articles.find(params[:id]) | 13 | reading_group_content = profile.articles.find(params[:id]) |
14 | - | ||
15 | reading = Kalibro::Reading.new params[:reading] | 14 | reading = Kalibro::Reading.new params[:reading] |
16 | 15 | ||
17 | if( reading.save(reading_group_content.reading_group_id) ) | 16 | if( reading.save(reading_group_content.reading_group_id) ) |
18 | - redirect_to "/#{profile.identifier}/#{reading_group_content.name.downcase.gsub(/\s/, '-').gsub(/[^0-9A-Za-z\-]/, '')}" | 17 | + redirect_to reading_group_content.view_url |
19 | else | 18 | else |
20 | redirect_to_error_page reading.errors[0].message | 19 | redirect_to_error_page reading.errors[0].message |
21 | end | 20 | end |
@@ -35,7 +34,7 @@ class MezuroPluginReadingController < MezuroPluginMyprofileController | @@ -35,7 +34,7 @@ class MezuroPluginReadingController < MezuroPluginMyprofileController | ||
35 | reading = Kalibro::Reading.new params[:reading] | 34 | reading = Kalibro::Reading.new params[:reading] |
36 | 35 | ||
37 | if( reading.save(reading_group_content.reading_group_id) ) | 36 | if( reading.save(reading_group_content.reading_group_id) ) |
38 | - redirect_to "/profile/#{profile.identifier}/plugin/mezuro/reading/show/#{reading_group_content.id}?reading_id=#{reading.id}" | 37 | + redirect_to reading_group_content.view_url |
39 | else | 38 | else |
40 | redirect_to_error_page reading.errors[0].message | 39 | redirect_to_error_page reading.errors[0].message |
41 | end | 40 | end |
@@ -46,7 +45,7 @@ class MezuroPluginReadingController < MezuroPluginMyprofileController | @@ -46,7 +45,7 @@ class MezuroPluginReadingController < MezuroPluginMyprofileController | ||
46 | reading = Kalibro::Reading.find params[:reading_id] | 45 | reading = Kalibro::Reading.find params[:reading_id] |
47 | reading.destroy | 46 | reading.destroy |
48 | if( reading.errors.empty? ) | 47 | if( reading.errors.empty? ) |
49 | - redirect_to "/#{profile.identifier}/#{reading_group_content.name.downcase.gsub(/\s/, '-')}" | 48 | + redirect_to reading_group_content.view_url |
50 | else | 49 | else |
51 | redirect_to_error_page reading.errors[0].message | 50 | redirect_to_error_page reading.errors[0].message |
52 | end | 51 | end |
plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb
@@ -25,7 +25,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController | @@ -25,7 +25,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController | ||
25 | 25 | ||
26 | if( repository.errors.empty? ) | 26 | if( repository.errors.empty? ) |
27 | repository.process | 27 | repository.process |
28 | - redirect_to "/profile/#{profile.identifier}/plugin/mezuro/repository/show/#{project_content.id}?repository_id=#{repository.id}" | 28 | + redirect_to(repository_url(project_content)) |
29 | else | 29 | else |
30 | redirect_to_error_page repository.errors[0].message | 30 | redirect_to_error_page repository.errors[0].message |
31 | end | 31 | end |
@@ -56,7 +56,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController | @@ -56,7 +56,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController | ||
56 | 56 | ||
57 | if( repository.errors.empty? ) | 57 | if( repository.errors.empty? ) |
58 | repository.process | 58 | repository.process |
59 | - redirect_to "/profile/#{profile.identifier}/plugin/mezuro/repository/show/#{project_content.id}?repository_id=#{repository.id}" | 59 | + redirect_to(repository_url(project_content)) |
60 | else | 60 | else |
61 | redirect_to_error_page repository.errors[0].message | 61 | redirect_to_error_page repository.errors[0].message |
62 | end | 62 | end |
@@ -76,10 +76,19 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController | @@ -76,10 +76,19 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController | ||
76 | repository = project_content.repositories.select{ |repository| repository.id.to_s == params[:repository_id] }.first | 76 | repository = project_content.repositories.select{ |repository| repository.id.to_s == params[:repository_id] }.first |
77 | repository.destroy | 77 | repository.destroy |
78 | if( repository.errors.empty? ) | 78 | if( repository.errors.empty? ) |
79 | - redirect_to "/#{profile.identifier}/#{project_content.name.downcase.gsub(/\s/, '-')}" | 79 | + redirect_to project_content.view_url |
80 | else | 80 | else |
81 | redirect_to_error_page repository.errors[0].message | 81 | redirect_to_error_page repository.errors[0].message |
82 | end | 82 | end |
83 | end | 83 | end |
84 | 84 | ||
85 | + def repository_url project_content | ||
86 | + url = project_content.view_url | ||
87 | + url[:controller] = controller_name | ||
88 | + url[:id] = project_content.id | ||
89 | + url[:repository_id] = params[:repository_id].to_i | ||
90 | + url[:action] = "show" | ||
91 | + url | ||
92 | + end | ||
93 | + | ||
85 | end | 94 | end |
plugins/mezuro/test/functional/myprofile/mezuro_plugin_metric_configuration_controller_test.rb
@@ -117,14 +117,14 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase | @@ -117,14 +117,14 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase | ||
117 | @native_metric_configuration.expects(:update_attributes).returns(true) #FIXME need .with(some_hash), should it mock the request?. | 117 | @native_metric_configuration.expects(:update_attributes).returns(true) #FIXME need .with(some_hash), should it mock the request?. |
118 | get :update, :profile => @profile.identifier, :id => @configuration_content.id, :metric_configuration => @native_metric_configuration_hash | 118 | get :update, :profile => @profile.identifier, :id => @configuration_content.id, :metric_configuration => @native_metric_configuration_hash |
119 | assert_equal @configuration_content, assigns(:configuration_content) | 119 | assert_equal @configuration_content, assigns(:configuration_content) |
120 | - assert_response 302 | 120 | + assert_response :redirect |
121 | end | 121 | end |
122 | 122 | ||
123 | should 'remove' do | 123 | should 'remove' do |
124 | Kalibro::MetricConfiguration.expects(:new).with({:id => @native_metric_configuration.id}).returns(@native_metric_configuration) | 124 | Kalibro::MetricConfiguration.expects(:new).with({:id => @native_metric_configuration.id}).returns(@native_metric_configuration) |
125 | @native_metric_configuration.expects(:destroy).returns() | 125 | @native_metric_configuration.expects(:destroy).returns() |
126 | get :remove, :profile => @profile.identifier, :id => @configuration_content.id, :metric_configuration_id => @native_metric_configuration.id | 126 | get :remove, :profile => @profile.identifier, :id => @configuration_content.id, :metric_configuration_id => @native_metric_configuration.id |
127 | - assert_response 302 | 127 | + assert_response :redirect |
128 | end | 128 | end |
129 | 129 | ||
130 | end | 130 | end |
plugins/mezuro/test/functional/myprofile/mezuro_plugin_range_controller_test.rb
@@ -34,11 +34,13 @@ class MezuroPluginRangeControllerTest < ActionController::TestCase | @@ -34,11 +34,13 @@ class MezuroPluginRangeControllerTest < ActionController::TestCase | ||
34 | 34 | ||
35 | should 'set correct attributes to create a new range' do | 35 | should 'set correct attributes to create a new range' do |
36 | Kalibro::Reading.expects(:readings_of).with(@metric_configuration.reading_group_id).returns([@reading]) | 36 | Kalibro::Reading.expects(:readings_of).with(@metric_configuration.reading_group_id).returns([@reading]) |
37 | - get :new, :profile => @profile.identifier, :id => @content.id, :metric_configuration_id => @metric_configuration.id, :reading_group_id => @metric_configuration.reading_group_id | 37 | + get :new, :profile => @profile.identifier, :id => @content.id, :metric_configuration_id => @metric_configuration.id, :reading_group_id => @metric_configuration.reading_group_id, :compound => @metric_configuration.metric.compound |
38 | assert_equal @content.id, assigns(:content_id) | 38 | assert_equal @content.id, assigns(:content_id) |
39 | assert_equal @metric_configuration.id, assigns(:metric_configuration_id) | 39 | assert_equal @metric_configuration.id, assigns(:metric_configuration_id) |
40 | assert_equal [[@reading.label,@reading.id]], assigns(:reading_labels_and_ids) | 40 | assert_equal [[@reading.label,@reading.id]], assigns(:reading_labels_and_ids) |
41 | - assert_response 200 | 41 | + assert_equal @metric_configuration.reading_group_id, assigns(:reading_group_id) |
42 | + assert_equal @metric_configuration.metric.compound, assigns(:compound) | ||
43 | + assert_response :success | ||
42 | end | 44 | end |
43 | 45 | ||
44 | should 'set correct attributes to edit a range' do | 46 | should 'set correct attributes to edit a range' do |
@@ -49,7 +51,7 @@ class MezuroPluginRangeControllerTest < ActionController::TestCase | @@ -49,7 +51,7 @@ class MezuroPluginRangeControllerTest < ActionController::TestCase | ||
49 | assert_equal @metric_configuration.id, assigns(:metric_configuration_id) | 51 | assert_equal @metric_configuration.id, assigns(:metric_configuration_id) |
50 | assert_equal [[@reading.label,@reading.id]], assigns(:reading_labels_and_ids) | 52 | assert_equal [[@reading.label,@reading.id]], assigns(:reading_labels_and_ids) |
51 | assert_equal @range, assigns(:range) | 53 | assert_equal @range, assigns(:range) |
52 | - assert_response 200 | 54 | + assert_response :success |
53 | end | 55 | end |
54 | 56 | ||
55 | should 'test create instance range' do | 57 | should 'test create instance range' do |
@@ -57,9 +59,11 @@ class MezuroPluginRangeControllerTest < ActionController::TestCase | @@ -57,9 +59,11 @@ class MezuroPluginRangeControllerTest < ActionController::TestCase | ||
57 | :metric_configuration_id => @metric_configuration.id, | 59 | :metric_configuration_id => @metric_configuration.id, |
58 | :range => @created_range.to_hash}).returns(:range_id => @range.id) | 60 | :range => @created_range.to_hash}).returns(:range_id => @range.id) |
59 | Kalibro::Reading.expects(:find).with(@created_range.reading_id).returns(@reading) | 61 | Kalibro::Reading.expects(:find).with(@created_range.reading_id).returns(@reading) |
60 | - get :create, :profile => @profile.identifier, :range => @created_range_hash, :metric_configuration_id => @metric_configuration.id | 62 | + get :create, :profile => @profile.identifier, :range => @created_range_hash, :metric_configuration_id => @metric_configuration.id, :reading_group_id => @metric_configuration.reading_group_id, :compound => @metric_configuration.metric.compound |
61 | assert_equal @range.id, assigns(:range).id | 63 | assert_equal @range.id, assigns(:range).id |
62 | - assert_response 200 | 64 | + assert_equal @metric_configuration.reading_group_id, assigns(:reading_group_id) |
65 | + assert_equal @metric_configuration.metric.compound, assigns(:compound) | ||
66 | + assert_response :success | ||
63 | end | 67 | end |
64 | 68 | ||
65 | should 'test update range' do | 69 | should 'test update range' do |
@@ -68,13 +72,13 @@ class MezuroPluginRangeControllerTest < ActionController::TestCase | @@ -68,13 +72,13 @@ class MezuroPluginRangeControllerTest < ActionController::TestCase | ||
68 | :range => @range.to_hash}).returns(:range_id => @range.id) | 72 | :range => @range.to_hash}).returns(:range_id => @range.id) |
69 | get :update, :profile => @profile.identifier, :range => @range_hash, :metric_configuration_id => @metric_configuration.id | 73 | get :update, :profile => @profile.identifier, :range => @range_hash, :metric_configuration_id => @metric_configuration.id |
70 | assert_equal @range.id, assigns(:range).id | 74 | assert_equal @range.id, assigns(:range).id |
71 | - assert_response 200 | 75 | + assert_response :success |
72 | end | 76 | end |
73 | 77 | ||
74 | should 'test remove range in native metric configuration' do | 78 | should 'test remove range in native metric configuration' do |
75 | Kalibro::Range.expects(:new).with({:id => @range.id}).returns(@range) | 79 | Kalibro::Range.expects(:new).with({:id => @range.id}).returns(@range) |
76 | @range.expects(:destroy).with().returns() | 80 | @range.expects(:destroy).with().returns() |
77 | get :remove, :profile => @profile.identifier, :id => @content.id, :metric_configuration_id => @metric_configuration.id, :range_id => @range.id, :compound => false | 81 | get :remove, :profile => @profile.identifier, :id => @content.id, :metric_configuration_id => @metric_configuration.id, :range_id => @range.id, :compound => false |
78 | - assert_response 302 | 82 | + assert_response :redirect |
79 | end | 83 | end |
80 | end | 84 | end |
plugins/mezuro/test/functional/profile/mezuro_plugin_module_result_controller_test.rb
@@ -32,7 +32,7 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase | @@ -32,7 +32,7 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase | ||
32 | get :module_result, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id] | 32 | get :module_result, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id] |
33 | assert_equal @module_result_hash[:grade].to_f, assigns(:module_result).grade | 33 | assert_equal @module_result_hash[:grade].to_f, assigns(:module_result).grade |
34 | assert_equal @metric_result_hash[:value].to_f, assigns(:metric_results).first.value | 34 | assert_equal @metric_result_hash[:value].to_f, assigns(:metric_results).first.value |
35 | - assert_response 200 | 35 | + assert_response :success |
36 | #TODO assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') | 36 | #TODO assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') |
37 | end | 37 | end |
38 | 38 | ||
@@ -42,7 +42,7 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase | @@ -42,7 +42,7 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase | ||
42 | returns({:date_metric_result => @date_metric_result_hash}) | 42 | returns({:date_metric_result => @date_metric_result_hash}) |
43 | get :metric_result_history, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id], :metric_name => metric_name | 43 | get :metric_result_history, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id], :metric_name => metric_name |
44 | assert_equal DateTime.parse(@date_metric_result_hash[:date]), assigns(:history).first.date | 44 | assert_equal DateTime.parse(@date_metric_result_hash[:date]), assigns(:history).first.date |
45 | - assert_response 200 | 45 | + assert_response :success |
46 | #TODO assert_select | 46 | #TODO assert_select |
47 | end | 47 | end |
48 | 48 | ||
@@ -51,7 +51,7 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase | @@ -51,7 +51,7 @@ class MezuroPluginModuleResultControllerTest < ActionController::TestCase | ||
51 | returns({:date_module_result => @date_module_result_hash}) | 51 | returns({:date_module_result => @date_module_result_hash}) |
52 | get :module_result_history, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id] | 52 | get :module_result_history, :profile => @profile.identifier, :module_result_id => @module_result_hash[:id] |
53 | assert_equal DateTime.parse(@date_module_result_hash[:date]), assigns(:history).first.date | 53 | assert_equal DateTime.parse(@date_module_result_hash[:date]), assigns(:history).first.date |
54 | - assert_response 200 | 54 | + assert_response :success |
55 | #TODO assert_select | 55 | #TODO assert_select |
56 | end | 56 | end |
57 | 57 |
plugins/mezuro/test/functional/profile/mezuro_plugin_processing_controller_test.rb
@@ -21,14 +21,14 @@ class MezuroPluginProcessingControllerTest < ActionController::TestCase | @@ -21,14 +21,14 @@ class MezuroPluginProcessingControllerTest < ActionController::TestCase | ||
21 | should 'render last processing state' do | 21 | should 'render last processing state' do |
22 | Kalibro::Processing.expects(:processing_of).with(@repository_id).returns(@processing) | 22 | Kalibro::Processing.expects(:processing_of).with(@repository_id).returns(@processing) |
23 | get :state, :profile => @profile.identifier, :repository_id => @repository_id | 23 | get :state, :profile => @profile.identifier, :repository_id => @repository_id |
24 | - assert_response 200 | 24 | + assert_response :success |
25 | assert_equal @processing.state, @response.body | 25 | assert_equal @processing.state, @response.body |
26 | end | 26 | end |
27 | 27 | ||
28 | should 'render a processing state in a specific date' do | 28 | should 'render a processing state in a specific date' do |
29 | Kalibro::Processing.expects(:processing_with_date_of).with(@repository_id, @processing.date).returns(@processing) | 29 | Kalibro::Processing.expects(:processing_with_date_of).with(@repository_id, @processing.date).returns(@processing) |
30 | get :state, :profile => @profile.identifier, :repository_id => @repository_id, :date => @processing.date | 30 | get :state, :profile => @profile.identifier, :repository_id => @repository_id, :date => @processing.date |
31 | - assert_response 200 | 31 | + assert_response :success |
32 | assert_equal @processing.state, @response.body | 32 | assert_equal @processing.state, @response.body |
33 | end | 33 | end |
34 | 34 | ||
@@ -36,7 +36,7 @@ class MezuroPluginProcessingControllerTest < ActionController::TestCase | @@ -36,7 +36,7 @@ class MezuroPluginProcessingControllerTest < ActionController::TestCase | ||
36 | Kalibro::Processing.expects(:request).with(:has_ready_processing, {:repository_id => @repository_id}).returns({:exists => false}) | 36 | Kalibro::Processing.expects(:request).with(:has_ready_processing, {:repository_id => @repository_id}).returns({:exists => false}) |
37 | Kalibro::Processing.expects(:request).with(:last_processing, :repository_id => @repository_id).returns({:processing => @processing_with_error_hash}) | 37 | Kalibro::Processing.expects(:request).with(:last_processing, :repository_id => @repository_id).returns({:processing => @processing_with_error_hash}) |
38 | get :processing, :profile => @profile.identifier, :repository_id => @repository_id | 38 | get :processing, :profile => @profile.identifier, :repository_id => @repository_id |
39 | - assert_response 200 | 39 | + assert_response :success |
40 | assert_equal @processing_with_error_hash[:state], assigns(:processing).state | 40 | assert_equal @processing_with_error_hash[:state], assigns(:processing).state |
41 | #TODO How to assert from view? assert_select('h3', 'ERROR') | 41 | #TODO How to assert from view? assert_select('h3', 'ERROR') |
42 | end | 42 | end |
@@ -45,7 +45,7 @@ class MezuroPluginProcessingControllerTest < ActionController::TestCase | @@ -45,7 +45,7 @@ class MezuroPluginProcessingControllerTest < ActionController::TestCase | ||
45 | Kalibro::Processing.expects(:request).with(:has_ready_processing, {:repository_id => @repository_id}).returns({:exists => true}) | 45 | Kalibro::Processing.expects(:request).with(:has_ready_processing, {:repository_id => @repository_id}).returns({:exists => true}) |
46 | Kalibro::Processing.expects(:request).with(:last_ready_processing, {:repository_id => @repository_id}).returns({:processing => @processing_hash}) | 46 | Kalibro::Processing.expects(:request).with(:last_ready_processing, {:repository_id => @repository_id}).returns({:processing => @processing_hash}) |
47 | get :processing, :profile => @profile.identifier, :repository_id => @repository_id | 47 | get :processing, :profile => @profile.identifier, :repository_id => @repository_id |
48 | - assert_response 200 | 48 | + assert_response :success |
49 | assert_select('h4', 'Last Result') | 49 | assert_select('h4', 'Last Result') |
50 | end | 50 | end |
51 | 51 | ||
@@ -53,7 +53,7 @@ class MezuroPluginProcessingControllerTest < ActionController::TestCase | @@ -53,7 +53,7 @@ class MezuroPluginProcessingControllerTest < ActionController::TestCase | ||
53 | Kalibro::Processing.expects(:request).with(:has_processing_after, {:repository_id => @repository_id, :date => @processing.date}).returns({:exists => true}) | 53 | Kalibro::Processing.expects(:request).with(:has_processing_after, {:repository_id => @repository_id, :date => @processing.date}).returns({:exists => true}) |
54 | Kalibro::Processing.expects(:request).with(:first_processing_after, :repository_id => @repository_id, :date => @processing.date).returns({:processing => @processing_hash}) | 54 | Kalibro::Processing.expects(:request).with(:first_processing_after, :repository_id => @repository_id, :date => @processing.date).returns({:processing => @processing_hash}) |
55 | get :processing, :profile => @profile.identifier, :repository_id => @repository_id, :date => @processing.date | 55 | get :processing, :profile => @profile.identifier, :repository_id => @repository_id, :date => @processing.date |
56 | - assert_response 200 | 56 | + assert_response :success |
57 | assert_select('h4', 'Last Result') | 57 | assert_select('h4', 'Last Result') |
58 | end | 58 | end |
59 | 59 |
plugins/mezuro/test/functional/profile/mezuro_plugin_repository_controller_test.rb
@@ -103,6 +103,7 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase | @@ -103,6 +103,7 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase | ||
103 | assert_equal @configuration.name, assigns(:configuration_name) | 103 | assert_equal @configuration.name, assigns(:configuration_name) |
104 | assert_equal @content.profile.identifier, assigns(:data_profile) | 104 | assert_equal @content.profile.identifier, assigns(:data_profile) |
105 | assert_equal @content.id, assigns(:data_content) | 105 | assert_equal @content.id, assigns(:data_content) |
106 | + assert_response :success | ||
106 | end | 107 | end |
107 | 108 | ||
108 | should 'destroy a repository' do | 109 | should 'destroy a repository' do |
plugins/mezuro/views/mezuro_plugin_metric_configuration/edit_native.html.erb
@@ -42,7 +42,7 @@ | @@ -42,7 +42,7 @@ | ||
42 | 42 | ||
43 | <br/> | 43 | <br/> |
44 | <% if owner %> | 44 | <% if owner %> |
45 | - <%= link_to_remote "New Range", :url => {:action =>"new", :controller => "mezuro_plugin_range", :id => @configuration_content.id, :metric_configuration_id => @metric_configuration.id, :reading_group_id => @metric_configuration.reading_group_id} %> | 45 | + <%= link_to_remote "New Range", :url => {:action =>"new", :controller => "mezuro_plugin_range", :id => @configuration_content.id, :metric_configuration_id => @metric_configuration.id, :reading_group_id => @metric_configuration.reading_group_id, :compound => @metric_configuration.metric.compound} %> |
46 | <% end %> | 46 | <% end %> |
47 | <div id="form" style="display:none"></div> | 47 | <div id="form" style="display:none"></div> |
48 | 48 |
plugins/mezuro/views/mezuro_plugin_range/_form.html.erb
1 | <%= hidden_field_tag :id, @content_id %> | 1 | <%= hidden_field_tag :id, @content_id %> |
2 | <%= hidden_field_tag :metric_configuration_id, @metric_configuration_id %> | 2 | <%= hidden_field_tag :metric_configuration_id, @metric_configuration_id %> |
3 | +<%= hidden_field_tag :reading_group_id, @reading_group_id %> | ||
4 | +<%= hidden_field_tag :compound, @compound %> | ||
3 | 5 | ||
4 | <%= f.hidden_field :id %> | 6 | <%= f.hidden_field :id %> |
5 | 7 |
plugins/mezuro/views/mezuro_plugin_range/create.rjs
1 | if @error.nil? | 1 | if @error.nil? |
2 | page.visual_effect :toggle_slide, "form" | 2 | page.visual_effect :toggle_slide, "form" |
3 | - page.insert_html :bottom, "ranges", :partial => "range", :locals => {:range => @range} | 3 | + page.insert_html :bottom, "ranges", :partial => "range", :locals => {:range => @range, :reading_group_id => @reading_group_id, :compound => @compound} |
4 | else | 4 | else |
5 | page.alert @error | 5 | page.alert @error |
6 | end | 6 | end |
plugins/mezuro/views/mezuro_plugin_reading/edit.html.erb
1 | <script src="/javascripts/colorpicker.js" type="text/javascript"></script> | 1 | <script src="/javascripts/colorpicker.js" type="text/javascript"></script> |
2 | <script src="/javascripts/colorpicker-noosfero.js" type="text/javascript"></script> | 2 | <script src="/javascripts/colorpicker-noosfero.js" type="text/javascript"></script> |
3 | -<h3> <%= link_to( @reading_group_name, homepage_url(@data_profile, @reading_group_name.downcase.gsub(/[^0-9A-Za-z\-]/, '')) ) %></h3> | 3 | +<h3> <%= link_to( @reading_group_name, homepage_url(@data_profile, @reading_group_name.downcase.gsub(/[^0-9A-Za-z\-]/, '-')) ) %></h3> |
4 | 4 | ||
5 | -<% form_for :reading, :url => {:action =>"create", :controller => "mezuro_plugin_reading"}, :method => :get do |f| %> | 5 | +<% form_for :reading, :url => {:action =>"update", :controller => "mezuro_plugin_reading"}, :method => :get do |f| %> |
6 | <%= hidden_field_tag :id, @reading_group_content_id %> | 6 | <%= hidden_field_tag :id, @reading_group_content_id %> |
7 | 7 | ||
8 | <%= f.hidden_field :id %> | 8 | <%= f.hidden_field :id %> |
plugins/mezuro/views/mezuro_plugin_reading/new.html.erb
1 | <script src="/javascripts/colorpicker.js" type="text/javascript"></script> | 1 | <script src="/javascripts/colorpicker.js" type="text/javascript"></script> |
2 | <script src="/javascripts/colorpicker-noosfero.js" type="text/javascript"></script> | 2 | <script src="/javascripts/colorpicker-noosfero.js" type="text/javascript"></script> |
3 | -<h3> <%= link_to( @reading_group_name, homepage_url(@data_profile, @reading_group_name.downcase.gsub(/[^0-9A-Za-z\-]/, '')) ) %></h3> | 3 | +<h3> <%= link_to( @reading_group_name, homepage_url(@data_profile, @reading_group_name.downcase.gsub(/[^0-9A-Za-z\-]/, '-')) ) %></h3> |
4 | 4 | ||
5 | <% form_for :reading, :url => {:action =>"create", :controller => "mezuro_plugin_reading"}, :method => :get do |f| %> | 5 | <% form_for :reading, :url => {:action =>"create", :controller => "mezuro_plugin_reading"}, :method => :get do |f| %> |
6 | <%= hidden_field_tag :id, @reading_group_content_id %> | 6 | <%= hidden_field_tag :id, @reading_group_content_id %> |