Commit 661871170792598fdc164fd19d3f10e47e60e143
Committed by
João M. M. da Silva
1 parent
4110f11d
Exists in
master
and in
29 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,7 +9,7 @@ class Kalibro::Model | ||
9 | 9 | ||
10 | def to_hash(options={}) | 10 | def to_hash(options={}) |
11 | hash = Hash.new | 11 | hash = Hash.new |
12 | - excepts = !options[:except].nil? ? options[:except] : [] | 12 | + excepts = options[:except].nil? ? [] : options[:except] |
13 | excepts << :errors | 13 | excepts << :errors |
14 | fields.each do |field| | 14 | fields.each do |field| |
15 | if(!excepts.include?(field)) | 15 | if(!excepts.include?(field)) |
@@ -50,7 +50,7 @@ class Kalibro::Model | @@ -50,7 +50,7 @@ class Kalibro::Model | ||
50 | 50 | ||
51 | def save | 51 | def save |
52 | begin | 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 | true | 54 | true |
55 | rescue Exception => exception | 55 | rescue Exception => exception |
56 | add_error exception | 56 | add_error exception |
plugins/mezuro/test/unit/kalibro/project_test.rb
@@ -55,7 +55,7 @@ class ProjectTest < ActiveSupport::TestCase | @@ -55,7 +55,7 @@ class ProjectTest < ActiveSupport::TestCase | ||
55 | 55 | ||
56 | should 'return true when project is saved successfully' do | 56 | should 'return true when project is saved successfully' do |
57 | id_from_kalibro = 1 | 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 | assert @created_project.save | 59 | assert @created_project.save |
60 | assert_equal id_from_kalibro, @created_project.id | 60 | assert_equal id_from_kalibro, @created_project.id |
61 | end | 61 | end |
plugins/mezuro/test/unit/kalibro/reading_group_test.rb
@@ -41,7 +41,7 @@ class ReadingGroupTest < ActiveSupport::TestCase | @@ -41,7 +41,7 @@ class ReadingGroupTest < ActiveSupport::TestCase | ||
41 | 41 | ||
42 | should 'return true when reading group is saved successfully' do | 42 | should 'return true when reading group is saved successfully' do |
43 | id_from_kalibro = 1 | 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 | assert @created_reading_group.save | 45 | assert @created_reading_group.save |
46 | assert_equal id_from_kalibro, @created_reading_group.id | 46 | assert_equal id_from_kalibro, @created_reading_group.id |
47 | end | 47 | end |
plugins/mezuro/test/unit/kalibro/reading_test.rb
@@ -37,7 +37,7 @@ class ReadingTest < ActiveSupport::TestCase | @@ -37,7 +37,7 @@ class ReadingTest < ActiveSupport::TestCase | ||
37 | 37 | ||
38 | should 'return true when reading is saved successfully' do | 38 | should 'return true when reading is saved successfully' do |
39 | id_from_kalibro = 1 | 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 | assert @created_reading.save | 41 | assert @created_reading.save |
42 | assert_equal id_from_kalibro, @created_reading.id | 42 | assert_equal id_from_kalibro, @created_reading.id |
43 | end | 43 | end |
plugins/mezuro/test/unit/kalibro/repository_test.rb
@@ -38,7 +38,7 @@ class RepositoryTest < ActiveSupport::TestCase | @@ -38,7 +38,7 @@ class RepositoryTest < ActiveSupport::TestCase | ||
38 | 38 | ||
39 | should 'return true when repository is saved successfully' do | 39 | should 'return true when repository is saved successfully' do |
40 | id_from_kalibro = 1 | 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 | assert @created_repository.save | 42 | assert @created_repository.save |
43 | assert_equal id_from_kalibro, @created_repository.id | 43 | assert_equal id_from_kalibro, @created_repository.id |
44 | end | 44 | end |