Commit 38d8bf14101b6b63bcac121580162047bfa57007
Committed by
Paulo Meireles
1 parent
8bc2bb1b
Exists in
master
and in
29 other branches
[Mezuro] Refactored duplicated code in controllers.
Showing
14 changed files
with
103 additions
and
180 deletions
Show diff stats
plugins/mezuro/controllers/myprofile/mezuro_plugin_metric_configuration_controller.rb
... | ... | @@ -14,26 +14,34 @@ class MezuroPluginMetricConfigurationController < MezuroPluginMyprofileControlle |
14 | 14 | @reading_group_names_and_ids = reading_group_names_and_ids |
15 | 15 | end |
16 | 16 | |
17 | - def create_native | |
17 | + def edit_native | |
18 | + params_to_edit_view | |
19 | + end | |
20 | + | |
21 | + def new_compound | |
22 | + @configuration_content = profile.articles.find(params[:id]) | |
23 | + @metric_configurations = @configuration_content.metric_configurations | |
24 | + @reading_group_names_and_ids = reading_group_names_and_ids | |
25 | + if configuration_content_has_errors? | |
26 | + redirect_to_error_page @configuration_content.errors[:base] | |
27 | + end | |
28 | + end | |
29 | + | |
30 | + def edit_compound | |
31 | + params_to_edit_view | |
32 | + end | |
33 | + | |
34 | + def create | |
18 | 35 | configuration_content = profile.articles.find(params[:id]) |
19 | 36 | metric_configuration = Kalibro::MetricConfiguration.create(params[:metric_configuration]) |
20 | 37 | |
21 | 38 | if metric_configuration_has_errors? metric_configuration |
22 | 39 | redirect_to_error_page metric_configuration.errors[0].message |
23 | 40 | else |
24 | - redirect_to(metric_configuration_url(configuration_content)) | |
41 | + redirect_to(metric_configuration_url(configuration_content)) | |
25 | 42 | end |
26 | 43 | end |
27 | 44 | |
28 | - def edit_native | |
29 | - @configuration_content = profile.articles.find(params[:id]) | |
30 | - metric_configurations = @configuration_content.metric_configurations | |
31 | - @metric_configuration = find_metric_configuration(metric_configurations, params[:metric_configuration_id].to_i) | |
32 | - @metric = @metric_configuration.metric | |
33 | - @reading_group_names_and_ids = reading_group_names_and_ids | |
34 | - @ranges = Kalibro::Range.ranges_of(@metric_configuration.id) | |
35 | - end | |
36 | - | |
37 | 45 | def update |
38 | 46 | @configuration_content = profile.articles.find(params[:id]) |
39 | 47 | metric_configurations = @configuration_content.metric_configurations |
... | ... | @@ -57,51 +65,22 @@ class MezuroPluginMetricConfigurationController < MezuroPluginMyprofileControlle |
57 | 65 | redirect_to configuration_content.view_url |
58 | 66 | end |
59 | 67 | end |
60 | - | |
61 | - def new_compound | |
62 | - @configuration_content = profile.articles.find(params[:id]) | |
63 | - @metric_configurations = @configuration_content.metric_configurations | |
64 | - @reading_group_names_and_ids = reading_group_names_and_ids | |
65 | - if configuration_content_has_errors? | |
66 | - redirect_to_error_page @configuration_content.errors[:base] | |
67 | - end | |
68 | - end | |
69 | - | |
70 | - def create_compound | |
71 | - configuration_content = profile.articles.find(params[:id]) | |
72 | - metric_configuration = Kalibro::MetricConfiguration.create(params[:metric_configuration]) | |
73 | - | |
74 | - if metric_configuration_has_errors? metric_configuration | |
75 | - redirect_to_error_page metric_configuration.errors[0].message | |
76 | - else | |
77 | - redirect_to(metric_configuration_url(configuration_content)) | |
78 | - end | |
79 | - end | |
80 | - | |
81 | - def edit_compound | |
82 | - @configuration_content = profile.articles.find(params[:id]) | |
83 | - @metric_configurations = @configuration_content.metric_configurations | |
84 | - @metric_configuration = find_metric_configuration(@metric_configurations, params[:metric_configuration_id].to_i) | |
85 | - @metric = @metric_configuration.metric | |
86 | - @reading_group_names_and_ids = reading_group_names_and_ids | |
87 | - @ranges = Kalibro::Range.ranges_of(@metric_configuration.id) | |
88 | - end | |
89 | 68 | |
90 | 69 | private |
91 | - | |
70 | + | |
92 | 71 | def find_metric_configuration (metric_configurations, metric_configuration_id) |
93 | 72 | metric_configurations.select {|metric_configuration| metric_configuration.id == metric_configuration_id }.first |
94 | 73 | end |
95 | - | |
74 | + | |
96 | 75 | def reading_group_names_and_ids |
97 | 76 | array = Kalibro::ReadingGroup.all.map { |reading_group| [reading_group.name, reading_group.id] } |
98 | 77 | array.sort { |x,y| x.first.downcase <=> y.first.downcase } |
99 | 78 | end |
100 | - | |
79 | + | |
101 | 80 | def metric_configuration_has_errors? metric_configuration |
102 | 81 | not metric_configuration.errors.empty? |
103 | 82 | end |
104 | - | |
83 | + | |
105 | 84 | def configuration_content_has_errors? |
106 | 85 | not @configuration_content.errors[:base].nil? |
107 | 86 | end |
... | ... | @@ -114,5 +93,14 @@ class MezuroPluginMetricConfigurationController < MezuroPluginMyprofileControlle |
114 | 93 | url[:action] = (params[:metric_configuration][:metric][:compound] ? "edit_compound" : "edit_native") |
115 | 94 | url |
116 | 95 | end |
117 | -end | |
118 | 96 | |
97 | + def params_to_edit_view | |
98 | + @configuration_content = profile.articles.find(params[:id]) | |
99 | + @metric_configurations = @configuration_content.metric_configurations | |
100 | + @metric_configuration = find_metric_configuration(@metric_configurations, params[:metric_configuration_id].to_i) | |
101 | + @metric = @metric_configuration.metric | |
102 | + @reading_group_names_and_ids = reading_group_names_and_ids | |
103 | + @ranges = Kalibro::Range.ranges_of(@metric_configuration.id) | |
104 | + end | |
105 | + | |
106 | +end | ... | ... |
plugins/mezuro/controllers/myprofile/mezuro_plugin_range_controller.rb
... | ... | @@ -3,44 +3,27 @@ class MezuroPluginRangeController < MezuroPluginMyprofileController |
3 | 3 | append_view_path File.join(File.dirname(__FILE__) + '/../../views') |
4 | 4 | |
5 | 5 | def new |
6 | - @content_id = params[:id].to_i | |
7 | - @metric_configuration_id = params[:metric_configuration_id].to_i | |
8 | - @reading_labels_and_ids = reading_labels_and_ids | |
9 | - @reading_group_id = params[:reading_group_id].to_i | |
10 | - @compound = params[:compound] | |
6 | + params_to_range_form | |
7 | + params_to_redirect | |
11 | 8 | end |
12 | 9 | |
13 | 10 | def edit |
14 | - @content_id = params[:id].to_i | |
15 | - @metric_configuration_id = params[:metric_configuration_id].to_i | |
11 | + params_to_range_form | |
16 | 12 | ranges = Kalibro::Range.ranges_of params[:metric_configuration_id].to_i |
17 | 13 | @range = (ranges.select { |range| range.id == params[:range_id].to_i }).first |
18 | - @reading_labels_and_ids = reading_labels_and_ids | |
19 | 14 | end |
20 | 15 | |
21 | 16 | def create |
22 | - metric_configuration_id = params[:metric_configuration_id].to_i | |
23 | - @reading_group_id = params[:reading_group_id].to_i | |
24 | - @compound = params[:compound] | |
25 | - @range = Kalibro::Range.new params[:range] | |
26 | - @range.save metric_configuration_id | |
27 | - if !@range.errors.empty? | |
28 | - @error = @range.errors[0].message | |
29 | - end | |
17 | + params_to_redirect | |
18 | + save_range | |
30 | 19 | end |
31 | 20 | |
32 | 21 | def update |
33 | - metric_configuration_id = params[:metric_configuration_id].to_i | |
34 | - @range = Kalibro::Range.new params[:range] | |
35 | - @range.save metric_configuration_id | |
36 | - if !@range.errors.empty? | |
37 | - @error = @range.errors[0].message | |
38 | - end | |
22 | + save_range | |
39 | 23 | end |
40 | 24 | |
41 | 25 | def remove |
42 | 26 | configuration_content = profile.articles.find(params[:id]) |
43 | - | |
44 | 27 | Kalibro::Range.new({:id => params[:range_id].to_i}).destroy |
45 | 28 | redirect_to(metric_configuration_url(configuration_content)) |
46 | 29 | end |
... | ... | @@ -61,4 +44,24 @@ class MezuroPluginRangeController < MezuroPluginMyprofileController |
61 | 44 | array.sort { |x,y| x.first.downcase <=> y.first.downcase } |
62 | 45 | end |
63 | 46 | |
47 | + def save_range | |
48 | + metric_configuration_id = params[:metric_configuration_id].to_i | |
49 | + @range = Kalibro::Range.new params[:range] | |
50 | + @range.save metric_configuration_id | |
51 | + if !@range.errors.empty? | |
52 | + @error = @range.errors[0].message | |
53 | + end | |
54 | + end | |
55 | + | |
56 | + def params_to_range_form | |
57 | + @content_id = params[:id].to_i | |
58 | + @metric_configuration_id = params[:metric_configuration_id].to_i | |
59 | + @reading_labels_and_ids = reading_labels_and_ids | |
60 | + end | |
61 | + | |
62 | + def params_to_redirect | |
63 | + @reading_group_id = params[:reading_group_id].to_i | |
64 | + @compound = params[:compound] | |
65 | + end | |
66 | + | |
64 | 67 | end | ... | ... |
plugins/mezuro/controllers/myprofile/mezuro_plugin_reading_controller.rb
1 | 1 | class MezuroPluginReadingController < MezuroPluginMyprofileController |
2 | 2 | |
3 | 3 | append_view_path File.join(File.dirname(__FILE__) + '/../../views') |
4 | - | |
4 | + | |
5 | 5 | def new |
6 | 6 | @reading_group_content = profile.articles.find(params[:id]) |
7 | 7 | end |
8 | - | |
9 | - def create | |
8 | + | |
9 | + def save | |
10 | 10 | reading_group_content = profile.articles.find(params[:id]) |
11 | 11 | reading = Kalibro::Reading.new params[:reading] |
12 | 12 | |
... | ... | @@ -22,17 +22,6 @@ class MezuroPluginReadingController < MezuroPluginMyprofileController |
22 | 22 | @reading = Kalibro::Reading.find params[:reading_id] |
23 | 23 | end |
24 | 24 | |
25 | - def update | |
26 | - reading_group_content = profile.articles.find(params[:id]) | |
27 | - reading = Kalibro::Reading.new params[:reading] | |
28 | - | |
29 | - if( reading.save(reading_group_content.reading_group_id) ) | |
30 | - redirect_to reading_group_content.view_url | |
31 | - else | |
32 | - redirect_to_error_page reading.errors[0].message | |
33 | - end | |
34 | - end | |
35 | - | |
36 | 25 | def destroy |
37 | 26 | reading_group_content = profile.articles.find(params[:id]) |
38 | 27 | reading = Kalibro::Reading.find params[:reading_id] |
... | ... | @@ -43,5 +32,5 @@ class MezuroPluginReadingController < MezuroPluginMyprofileController |
43 | 32 | redirect_to_error_page reading.errors[0].message |
44 | 33 | end |
45 | 34 | end |
46 | - | |
35 | + | |
47 | 36 | end | ... | ... |
plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb
1 | 1 | class MezuroPluginRepositoryController < MezuroPluginProfileController |
2 | 2 | |
3 | 3 | append_view_path File.join(File.dirname(__FILE__) + '/../../views') |
4 | - | |
5 | - def new | |
6 | - @project_content = profile.articles.find(params[:id]) | |
7 | - | |
8 | - @repository_types = Kalibro::Repository.repository_types | |
9 | - | |
10 | - configurations = Kalibro::Configuration.all | |
11 | - configurations = [] if (configurations.nil?) | |
12 | - @configuration_select = configurations.map do |configuration| | |
13 | - [configuration.name,configuration.id] | |
14 | - end | |
15 | - end | |
16 | - | |
17 | - def create | |
18 | - project_content = profile.articles.find(params[:id]) | |
19 | 4 | |
20 | - repository = Kalibro::Repository.new( params[:repository] ) | |
21 | - repository.save(project_content.project_id) | |
22 | - | |
23 | - if( repository.errors.empty? ) | |
24 | - repository.process | |
25 | - redirect_to(repository_url(project_content)) | |
26 | - else | |
27 | - redirect_to_error_page repository.errors[0].message | |
28 | - end | |
5 | + def new | |
6 | + params_repository_form | |
29 | 7 | end |
30 | 8 | |
31 | 9 | def edit |
32 | - @project_content = profile.articles.find(params[:id]) | |
33 | - @repository_types = Kalibro::Repository.repository_types | |
34 | - | |
35 | - configurations = Kalibro::Configuration.all | |
36 | - configurations = [] if (configurations.nil?) | |
37 | - @configuration_select = configurations.map do |configuration| | |
38 | - [configuration.name,configuration.id] | |
39 | - end | |
40 | - | |
10 | + params_repository_form | |
41 | 11 | @repository = @project_content.repositories.select{ |repository| repository.id.to_s == params[:repository_id] }.first |
42 | 12 | end |
43 | 13 | |
44 | - def update | |
14 | + def save | |
45 | 15 | project_content = profile.articles.find(params[:id]) |
46 | - | |
16 | + | |
47 | 17 | repository = Kalibro::Repository.new( params[:repository] ) |
48 | 18 | repository.save(project_content.project_id) |
49 | 19 | |
... | ... | @@ -71,6 +41,8 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController |
71 | 41 | redirect_to_error_page repository.errors[0].message |
72 | 42 | end |
73 | 43 | end |
44 | + | |
45 | + private | |
74 | 46 | |
75 | 47 | def repository_url project_content |
76 | 48 | url = project_content.view_url |
... | ... | @@ -80,5 +52,16 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController |
80 | 52 | url[:action] = "show" |
81 | 53 | url |
82 | 54 | end |
83 | - | |
55 | + | |
56 | + def params_repository_form | |
57 | + @project_content = profile.articles.find(params[:id]) | |
58 | + @repository_types = Kalibro::Repository.repository_types | |
59 | + | |
60 | + configurations = Kalibro::Configuration.all | |
61 | + configurations = [] if (configurations.nil?) | |
62 | + @configuration_select = configurations.map do |configuration| | |
63 | + [configuration.name,configuration.id] | |
64 | + end | |
65 | + end | |
66 | + | |
84 | 67 | end | ... | ... |
plugins/mezuro/test/functional/myprofile/mezuro_plugin_metric_configuration_controller_test.rb
... | ... | @@ -14,7 +14,7 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase |
14 | 14 | @controller = MezuroPluginMetricConfigurationController.new |
15 | 15 | @request = ActionController::TestRequest.new |
16 | 16 | @response = ActionController::TestResponse.new |
17 | - @profile = fast_create(Community) #FIXME Should be a person, not a community | |
17 | + @profile = fast_create(Profile) | |
18 | 18 | |
19 | 19 | @configuration = ConfigurationFixtures.configuration |
20 | 20 | @created_configuration = ConfigurationFixtures.created_configuration |
... | ... | @@ -61,12 +61,6 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase |
61 | 61 | assert_response :success |
62 | 62 | end |
63 | 63 | |
64 | - should 'create native' do | |
65 | - Kalibro::MetricConfiguration.expects(:create).returns(@native_metric_configuration) #FIXME need .with(some_hash), should it mock the request?. | |
66 | - get :create_native, :profile => @profile.identifier, :id => @configuration_content.id, :metric_configuration => @native_metric_configuration_hash | |
67 | - assert_response :redirect | |
68 | - end | |
69 | - | |
70 | 64 | should 'edit native' do |
71 | 65 | Kalibro::MetricConfiguration.expects(:metric_configurations_of).with(@configuration.id).returns([@native_metric_configuration]) |
72 | 66 | Kalibro::ReadingGroup.expects(:all).returns([@reading_group]) |
... | ... | @@ -91,12 +85,6 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase |
91 | 85 | assert_response :success |
92 | 86 | end |
93 | 87 | |
94 | - should 'create compound' do | |
95 | - Kalibro::MetricConfiguration.expects(:create).returns(@compound_metric_configuration) #FIXME need .with(some_hash), should it mock the request?. | |
96 | - get :create_compound, :profile => @profile.identifier, :id => @configuration_content.id, :metric_configuration => @compound_metric_configuration_hash | |
97 | - assert_response :redirect | |
98 | - end | |
99 | - | |
100 | 88 | should 'edit compound' do |
101 | 89 | Kalibro::MetricConfiguration.expects(:metric_configurations_of).with(@configuration.id).returns([@compound_metric_configuration]) |
102 | 90 | Kalibro::ReadingGroup.expects(:all).returns([@reading_group]) |
... | ... | @@ -112,6 +100,12 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase |
112 | 100 | assert_response :success |
113 | 101 | end |
114 | 102 | |
103 | + should 'create' do | |
104 | + Kalibro::MetricConfiguration.expects(:create).returns(@compound_metric_configuration) #FIXME need .with(some_hash), should it mock the request?. | |
105 | + get :create, :profile => @profile.identifier, :id => @configuration_content.id, :metric_configuration => @compound_metric_configuration_hash | |
106 | + assert_response :redirect | |
107 | + end | |
108 | + | |
115 | 109 | should 'update' do |
116 | 110 | Kalibro::MetricConfiguration.expects(:metric_configurations_of).with(@configuration_content.configuration_id).returns([@native_metric_configuration]) |
117 | 111 | @native_metric_configuration.expects(:update_attributes).returns(true) #FIXME need .with(some_hash), should it mock the request?. | ... | ... |
plugins/mezuro/test/functional/myprofile/mezuro_plugin_range_controller_test.rb
... | ... | @@ -12,7 +12,7 @@ class MezuroPluginRangeControllerTest < ActionController::TestCase |
12 | 12 | @controller = MezuroPluginRangeController.new |
13 | 13 | @request = ActionController::TestRequest.new |
14 | 14 | @response = ActionController::TestResponse.new |
15 | - @profile = fast_create(Community) | |
15 | + @profile = fast_create(Profile) | |
16 | 16 | |
17 | 17 | @metric_configuration = MetricConfigurationFixtures.amloc_metric_configuration |
18 | 18 | @metric_configuration_hash = MetricConfigurationFixtures.amloc_metric_configuration_hash | ... | ... |
plugins/mezuro/test/functional/myprofile/mezuro_plugin_reading_controller_test.rb
... | ... | @@ -9,7 +9,7 @@ class MezuroPluginReadingControllerTest < ActionController::TestCase |
9 | 9 | @controller = MezuroPluginReadingController.new |
10 | 10 | @request = ActionController::TestRequest.new |
11 | 11 | @response = ActionController::TestResponse.new |
12 | - @profile = fast_create(Community) | |
12 | + @profile = fast_create(Profile) | |
13 | 13 | |
14 | 14 | @reading = ReadingFixtures.reading |
15 | 15 | @created_reading = ReadingFixtures.created_reading |
... | ... | @@ -29,7 +29,7 @@ class MezuroPluginReadingControllerTest < ActionController::TestCase |
29 | 29 | should 'create a reading' do |
30 | 30 | Kalibro::Reading.expects(:new).with(@reading_hash.to_s).returns(@created_reading) |
31 | 31 | @created_reading.expects(:save).with(@content.reading_group_id).returns(true) |
32 | - get :create, :profile => @profile.identifier, :id => @content.id, :reading => @reading_hash | |
32 | + get :save, :profile => @profile.identifier, :id => @content.id, :reading => @reading_hash | |
33 | 33 | assert @created_reading.errors.empty? |
34 | 34 | assert_response :redirect |
35 | 35 | end |
... | ... | @@ -38,7 +38,7 @@ class MezuroPluginReadingControllerTest < ActionController::TestCase |
38 | 38 | @created_reading.errors = [Exception.new] |
39 | 39 | Kalibro::Reading.expects(:new).with(@reading_hash.to_s).returns(@created_reading) |
40 | 40 | @created_reading.expects(:save).with(@content.reading_group_id).returns(false) |
41 | - get :create, :profile => @profile.identifier, :id => @content.id, :reading => @reading_hash | |
41 | + get :save, :profile => @profile.identifier, :id => @content.id, :reading => @reading_hash | |
42 | 42 | assert !@created_reading.errors.empty? |
43 | 43 | assert_response :redirect |
44 | 44 | end |
... | ... | @@ -51,22 +51,6 @@ class MezuroPluginReadingControllerTest < ActionController::TestCase |
51 | 51 | assert_response :success |
52 | 52 | end |
53 | 53 | |
54 | - should 'update a reading' do | |
55 | - Kalibro::Reading.expects(:new).with(@reading_hash.to_s).returns(@reading) | |
56 | - @reading.expects(:save).with(@content.reading_group_id).returns(true) | |
57 | - get :update, :profile => @profile.identifier, :id => @content.id, :reading => @reading_hash | |
58 | - assert @reading.errors.empty? | |
59 | - assert_response :redirect | |
60 | - end | |
61 | - | |
62 | - should 'put an Exception in reading when an error occurs in update action' do | |
63 | - @reading.errors = [Exception.new] | |
64 | - Kalibro::Reading.expects(:new).with(@reading_hash.to_s).returns(@reading) | |
65 | - @reading.expects(:save).with(@content.reading_group_id).returns(false) | |
66 | - get :update, :profile => @profile.identifier, :id => @content.id, :reading => @reading_hash | |
67 | - assert_response :redirect | |
68 | - end | |
69 | - | |
70 | 54 | should 'destroy a reading' do |
71 | 55 | @reading.expects(:destroy) |
72 | 56 | Kalibro::Reading.expects(:find).with(@reading.id.to_s).returns(@reading) | ... | ... |
plugins/mezuro/test/functional/profile/mezuro_plugin_repository_controller_test.rb
... | ... | @@ -38,20 +38,20 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase |
38 | 38 | assert_response :success |
39 | 39 | end |
40 | 40 | |
41 | - should 'create a repository' do | |
41 | + should 'save a repository' do | |
42 | 42 | Kalibro::Repository.expects(:new).returns(@repository) |
43 | 43 | @repository.expects(:save).with(@content.project_id).returns(true) |
44 | 44 | @repository.expects(:process) |
45 | - get :create, :profile => @profile.identifier, :id => @content.id, :repository => @repository_hash | |
45 | + get :save, :profile => @profile.identifier, :id => @content.id, :repository => @repository_hash | |
46 | 46 | assert @repository.errors.empty? |
47 | 47 | assert_response :redirect |
48 | 48 | end |
49 | 49 | |
50 | - should 'not create a repository' do | |
50 | + should 'not save a repository' do | |
51 | 51 | @repository.errors = [Exception.new] |
52 | 52 | Kalibro::Repository.expects(:new).returns(@repository) |
53 | 53 | @repository.expects(:save).with(@content.project_id).returns(false) |
54 | - get :create, :profile => @profile.identifier, :id => @content.id, :repository => @repository_hash | |
54 | + get :save, :profile => @profile.identifier, :id => @content.id, :repository => @repository_hash | |
55 | 55 | assert !@repository.errors.empty? |
56 | 56 | assert_response :redirect |
57 | 57 | end |
... | ... | @@ -71,24 +71,6 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase |
71 | 71 | assert_response :success |
72 | 72 | end |
73 | 73 | |
74 | - should 'update a repository' do | |
75 | - Kalibro::Repository.expects(:new).returns(@repository) | |
76 | - @repository.expects(:save).with(@content.project_id).returns(true) | |
77 | - Kalibro::Repository.expects(:request).with(:process_repository, {:repository_id => @repository.id}) | |
78 | - get :update, :profile => @profile.identifier, :id => @content.id, :repository => @repository_hash | |
79 | - assert @repository.errors.empty? | |
80 | - assert_response :redirect | |
81 | - end | |
82 | - | |
83 | - should 'not update a repository' do | |
84 | - @repository.errors = [Exception.new] | |
85 | - Kalibro::Repository.expects(:new).returns(@repository) | |
86 | - @repository.expects(:save).with(@content.project_id).returns(false) | |
87 | - get :update, :profile => @profile.identifier, :id => @content.id, :repository => @repository_hash | |
88 | - assert !@repository.errors.empty? | |
89 | - assert_response :redirect | |
90 | - end | |
91 | - | |
92 | 74 | should 'set variables to show a repository' do |
93 | 75 | Kalibro::Repository.expects(:repositories_of).with(@content.project_id).returns([@repository]) |
94 | 76 | Kalibro::Configuration.expects(:configuration_of).with(@repository.id).returns(@configuration) | ... | ... |
plugins/mezuro/views/mezuro_plugin_metric_configuration/new_compound.html.erb
1 | 1 | <h2><%= link_to("#{@configuration_content.name} Configuration", @configuration_content.view_url) %></h2> |
2 | 2 | |
3 | -<% form_for :metric_configuration, :url => {:action =>"create_compound", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %> | |
3 | +<% form_for :metric_configuration, :url => {:action =>"create", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %> | |
4 | 4 | <%= hidden_field_tag :id, @configuration_content.id %> |
5 | 5 | <%= f.hidden_field :configuration_id, :value => @configuration_content.configuration_id %> |
6 | 6 | ... | ... |
plugins/mezuro/views/mezuro_plugin_metric_configuration/new_native.html.erb
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | |
3 | 3 | <h2><%= link_to("#{@configuration_content.name} Configuration", @configuration_content.view_url) %></h2> |
4 | 4 | <!-- TODO This form should be a partial similar to _native_metric_configuration_form.rhtml --> |
5 | -<% form_for :metric_configuration, :url => {:action =>"create_native", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %> | |
5 | +<% form_for :metric_configuration, :url => {:action =>"create", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %> | |
6 | 6 | |
7 | 7 | <%= hidden_field_tag :id, @configuration_content.id %> |
8 | 8 | <%= f.hidden_field :configuration_id, :value => @configuration_content.configuration_id %> | ... | ... |
plugins/mezuro/views/mezuro_plugin_reading/edit.html.erb
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | <script src="/javascripts/colorpicker-noosfero.js" type="text/javascript"></script> |
3 | 3 | <h2><%= link_to("#{@reading_group_content.name} Reading Group", @reading_group_content.view_url) %></h2> |
4 | 4 | |
5 | -<% form_for :reading, :url => {:action =>"update", :controller => "mezuro_plugin_reading"}, :method => :get do |f| %> | |
5 | +<% form_for :reading, :url => {:action =>"save", :controller => "mezuro_plugin_reading"}, :method => :get do |f| %> | |
6 | 6 | <%= hidden_field_tag :id, @reading_group_content.id %> |
7 | 7 | |
8 | 8 | <%= f.hidden_field :id %> | ... | ... |
plugins/mezuro/views/mezuro_plugin_reading/new.html.erb
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | <script src="/javascripts/colorpicker-noosfero.js" type="text/javascript"></script> |
3 | 3 | <h2><%= link_to("#{@reading_group_content.name} Reading Group", @reading_group_content.view_url) %></h2> |
4 | 4 | |
5 | -<% form_for :reading, :url => {:action =>"create", :controller => "mezuro_plugin_reading"}, :method => :get do |f| %> | |
5 | +<% form_for :reading, :url => {:action =>"save", :controller => "mezuro_plugin_reading"}, :method => :get do |f| %> | |
6 | 6 | <%= hidden_field_tag :id, @reading_group_content.id %> |
7 | 7 | |
8 | 8 | <%= required labelled_form_field _('label:'), f.text_field(:label) %> | ... | ... |
plugins/mezuro/views/mezuro_plugin_repository/edit.html.erb
1 | 1 | <h2><%= link_to("#{@project_content.name} Project", @project_content.view_url) %></h2> |
2 | 2 | |
3 | -<% form_for :repository, :url => {:action =>"update", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %> | |
3 | +<% form_for :repository, :url => {:action =>"save", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %> | |
4 | 4 | <%= hidden_field_tag :id, @project_content.id %> |
5 | 5 | |
6 | 6 | <%= f.hidden_field :id%> | ... | ... |
plugins/mezuro/views/mezuro_plugin_repository/new.html.erb
1 | 1 | <h2><%= link_to("#{@project_content.name} Project", @project_content.view_url) %></h2> |
2 | 2 | |
3 | -<% form_for :repository, :url => {:action =>"create", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %> | |
3 | +<% form_for :repository, :url => {:action =>"save", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %> | |
4 | 4 | <%= hidden_field_tag :id, @project_content.id %> |
5 | 5 | |
6 | 6 | <%= required labelled_form_field _('Name:'), f.text_field(:name) %> | ... | ... |