Commit 661871170792598fdc164fd19d3f10e47e60e143
Committed by
João M. M. da Silva
1 parent
4110f11d
Exists in
staging
and in
42 other branches
[Mezuro] fixed save action in model.rb.
Showing
5 changed files
with
6 additions
and
6 deletions
Show diff stats
plugins/mezuro/lib/kalibro/model.rb
| ... | ... | @@ -9,7 +9,7 @@ class Kalibro::Model |
| 9 | 9 | |
| 10 | 10 | def to_hash(options={}) |
| 11 | 11 | hash = Hash.new |
| 12 | - excepts = !options[:except].nil? ? options[:except] : [] | |
| 12 | + excepts = options[:except].nil? ? [] : options[:except] | |
| 13 | 13 | excepts << :errors |
| 14 | 14 | fields.each do |field| |
| 15 | 15 | if(!excepts.include?(field)) |
| ... | ... | @@ -50,7 +50,7 @@ class Kalibro::Model |
| 50 | 50 | |
| 51 | 51 | def save |
| 52 | 52 | begin |
| 53 | - self.id = self.class.request(save_endpoint, save_action, save_params) | |
| 53 | + self.id = self.class.request(save_endpoint, save_action, save_params)["#{class_name.underscore}_id".to_sym] | |
| 54 | 54 | true |
| 55 | 55 | rescue Exception => exception |
| 56 | 56 | add_error exception | ... | ... |
plugins/mezuro/test/unit/kalibro/project_test.rb
| ... | ... | @@ -55,7 +55,7 @@ class ProjectTest < ActiveSupport::TestCase |
| 55 | 55 | |
| 56 | 56 | should 'return true when project is saved successfully' do |
| 57 | 57 | id_from_kalibro = 1 |
| 58 | - Kalibro::Project.expects(:request).with("Project", :save_project, {:project => @created_project.to_hash}).returns(id_from_kalibro) | |
| 58 | + Kalibro::Project.expects(:request).with("Project", :save_project, {:project => @created_project.to_hash}).returns(:project_id => id_from_kalibro) | |
| 59 | 59 | assert @created_project.save |
| 60 | 60 | assert_equal id_from_kalibro, @created_project.id |
| 61 | 61 | end | ... | ... |
plugins/mezuro/test/unit/kalibro/reading_group_test.rb
| ... | ... | @@ -41,7 +41,7 @@ class ReadingGroupTest < ActiveSupport::TestCase |
| 41 | 41 | |
| 42 | 42 | should 'return true when reading group is saved successfully' do |
| 43 | 43 | id_from_kalibro = 1 |
| 44 | - Kalibro::ReadingGroup.expects(:request).with("ReadingGroup", :save_reading_group, {:reading_group => @created_reading_group.to_hash}).returns(id_from_kalibro) | |
| 44 | + Kalibro::ReadingGroup.expects(:request).with("ReadingGroup", :save_reading_group, {:reading_group => @created_reading_group.to_hash}).returns(:reading_group_id => id_from_kalibro) | |
| 45 | 45 | assert @created_reading_group.save |
| 46 | 46 | assert_equal id_from_kalibro, @created_reading_group.id |
| 47 | 47 | end | ... | ... |
plugins/mezuro/test/unit/kalibro/reading_test.rb
| ... | ... | @@ -37,7 +37,7 @@ class ReadingTest < ActiveSupport::TestCase |
| 37 | 37 | |
| 38 | 38 | should 'return true when reading is saved successfully' do |
| 39 | 39 | id_from_kalibro = 1 |
| 40 | - Kalibro::Reading.expects(:request).with("Reading", :save_reading, {:reading => @created_reading.to_hash}).returns(id_from_kalibro) | |
| 40 | + Kalibro::Reading.expects(:request).with("Reading", :save_reading, {:reading => @created_reading.to_hash}).returns(:reading_id => id_from_kalibro) | |
| 41 | 41 | assert @created_reading.save |
| 42 | 42 | assert_equal id_from_kalibro, @created_reading.id |
| 43 | 43 | end | ... | ... |
plugins/mezuro/test/unit/kalibro/repository_test.rb
| ... | ... | @@ -38,7 +38,7 @@ class RepositoryTest < ActiveSupport::TestCase |
| 38 | 38 | |
| 39 | 39 | should 'return true when repository is saved successfully' do |
| 40 | 40 | id_from_kalibro = 1 |
| 41 | - Kalibro::Repository.expects(:request).with("Repository", :save_repository, {:repository => @created_repository.to_hash}).returns(id_from_kalibro) | |
| 41 | + Kalibro::Repository.expects(:request).with("Repository", :save_repository, {:repository => @created_repository.to_hash}).returns(:repository_id => id_from_kalibro) | |
| 42 | 42 | assert @created_repository.save |
| 43 | 43 | assert_equal id_from_kalibro, @created_repository.id |
| 44 | 44 | end | ... | ... |