Permalink
Browse files

Remove duplicate multi count dashboard methods. Update tests to ensur…

…e single method will accept variable methods of passing in the uids
  • Loading branch information...
1 parent 8cbb6bb commit 74376ba159048dc8243eed1179e5d8b9c55c14ea @davekrupinski davekrupinski committed with mmangino Mar 2, 2010
Showing with 22 additions and 19 deletions.
  1. +2 −14 lib/facebooker/models/user.rb
  2. +20 −5 test/facebooker/models/user_test.rb
@@ -532,24 +532,12 @@ def self.dashboard_multi_set_count(ids)
# Facebooker::User.dashboard_multi_increment_count ['1234', '5678']
def self.dashboard_multi_increment_count(*uids)
- Facebooker::Session.create.post("facebook.dashboard.multiIncrementCount", :uids => uids.flatten.to_json)
+ Facebooker::Session.create.post("facebook.dashboard.multiIncrementCount", :uids => uids.flatten.collect{ |uid| uid.to_s }.to_json)
end
# Facebooker::User.dashboard_multi_decrement_count ['1234', '5678']
def self.dashboard_multi_decrement_count(*uids)
- Facebooker::Session.create.post("facebook.dashboard.multiDecrementCount", :uids => uids.flatten.to_json)
- end
-
- def self.dashboard_multi_set_count(ids)
- Facebooker::Session.create.post("facebook.dashboard.multiSetCount", :ids => ids.to_json)
- end
-
- def self.dashboard_multi_increment_count(uids)
- Facebooker::Session.create.post("facebook.dashboard.multiIncrementCount", :uids => uids.to_json)
- end
-
- def self.dashboard_multi_decrement_count(uids)
- Facebooker::Session.create.post("facebook.dashboard.multiDecrementCount", :uids => uids.to_json)
+ Facebooker::Session.create.post("facebook.dashboard.multiDecrementCount", :uids => uids.flatten.collect{ |uid| uid.to_s }.to_json)
end
@@ -439,7 +439,17 @@ def test_parse_dashboard_multi_get_count
assert_equal({ '1234' => '11', '4321' => '22' }, Facebooker::User.dashboard_multi_get_count(['1234', '4321']))
end
- def test_can_dashboard_multi_increment_count
+ def test_can_dashboard_multi_increment_count_with_single_uid
+ Facebooker::Session.any_instance.expects(:post).with('facebook.dashboard.multiIncrementCount', :uids => ['8675309'].to_json)
+ Facebooker::User.dashboard_multi_increment_count 8675309
+ end
+
+ def test_can_dashboard_multi_increment_count_with_multiple_uids
+ Facebooker::Session.any_instance.expects(:post).with('facebook.dashboard.multiIncrementCount', :uids => ['8675309', '555'].to_json)
+ Facebooker::User.dashboard_multi_increment_count 8675309, 555
+ end
+
+ def test_can_dashboard_multi_increment_count_with_array_of_uids
Facebooker::Session.any_instance.expects(:post).with('facebook.dashboard.multiIncrementCount', :uids => ['1234', '4321'].to_json)
Facebooker::User.dashboard_multi_increment_count ['1234', '4321']
end
@@ -449,12 +459,17 @@ def test_parse_dashboard_multi_increment_count
assert_equal({ '1234' => '1', '4321' => '1' }, Facebooker::User.dashboard_multi_increment_count(['1234', '4321']))
end
- def test_can_dashboard_multi_decrement_count
- Facebooker::Session.any_instance.expects(:post).with('facebook.dashboard.multiDecrementCount', :uids => ['1234', '4321'].to_json)
- Facebooker::User.dashboard_multi_decrement_count ['1234', '4321']
+ def test_can_dashboard_multi_decrement_count_with_single_uid
+ Facebooker::Session.any_instance.expects(:post).with('facebook.dashboard.multiDecrementCount', :uids => ['99999999'].to_json)
+ Facebooker::User.dashboard_multi_decrement_count 99999999
+ end
+
+ def test_can_dashboard_multi_decrement_count_with_multiple_uids
+ Facebooker::Session.any_instance.expects(:post).with('facebook.dashboard.multiDecrementCount', :uids => ['1111', '2222'].to_json)
+ Facebooker::User.dashboard_multi_decrement_count 1111, 2222
end
- def test_parse_dashboard_multi_decrement_count
+ def test_parse_dashboard_multi_decrement_count_with_array_of_uids
expect_http_posts_with_responses(dashboard_multi_decrement_count_xml)
assert_equal({ '1234' => '1', '4321' => '1' }, Facebooker::User.dashboard_multi_decrement_count(['1234', '4321']))
end

0 comments on commit 74376ba

Please sign in to comment.