latompa-fleakr 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@ module Fleakr
5
5
  include Fleakr::Support::Object
6
6
 
7
7
  flickr_attribute :id, :from => '@nsid'
8
- flickr_attribute :username
8
+ flickr_attribute :username,:realname,:location
9
9
  flickr_attribute :icon_server, :from => '@iconserver'
10
10
  flickr_attribute :icon_farm, :from => '@iconfarm'
11
11
 
@@ -19,7 +19,7 @@ module Fleakr
19
19
  # Retrieve a list of contacts for an authenticated user
20
20
  def self.find_all_contacts(params={})
21
21
  response = Fleakr::Api::MethodRequest.with_response!('contacts.getList',params)
22
- (response.body/'contacts/contact').map {|c| Contact.new(c).to_user }
22
+ (response.body/'contacts/contact').map {|c| Contact.new(c) }
23
23
  end
24
24
 
25
25
  def to_user
@@ -61,7 +61,7 @@ module Fleakr
61
61
  find_one :by_email, :using => :find_email, :call => 'people.findByEmail'
62
62
  find_one :by_id, :using => :user_id, :call => 'people.getInfo'
63
63
 
64
- lazily_load :name, :photos_url, :profile_url, :photos_count, :with => :load_info
64
+ lazily_load :name, :photos_url, :profile_url, :photos_count, :location, :with => :load_info
65
65
  lazily_load :icon_server, :icon_farm, :pro, :admin, :with => :load_info
66
66
 
67
67
  scoped_search
@@ -5,25 +5,26 @@ module Fleakr::Objects
5
5
 
6
6
  context "The Contact class" do
7
7
 
8
- setup do
9
- @user_1 = stub()
10
- @user_2 = stub()
11
- @contact_1, @contact_2 = [stub(:to_user => @user_1), stub(:to_user => @user_2)]
12
-
13
- end
14
-
15
8
  should "return a list of users for a specified user's contacts" do
9
+ # user_1, user_2 = [stub(), stub()]
10
+ user_1 = stub()
11
+ user_2 = stub()
12
+
13
+ contact_1, contact_2 = [stub(:to_user => user_1), stub(:to_user => user_2)]
14
+
16
15
  response = mock_request_cycle :for => 'contacts.getPublicList', :with => {:user_id => '1'}
17
16
 
18
17
  contact_1_doc, contact_2_doc = (response.body/'rsp/contacts/contact').to_a
19
18
 
20
- Contact.stubs(:new).with(contact_1_doc).returns(@contact_1)
21
- Contact.stubs(:new).with(contact_2_doc).returns(@contact_2)
22
- Contact.find_all_by_user_id('1').should == [@user_1, @user_2]
19
+ Contact.stubs(:new).with(contact_1_doc).returns(contact_1)
20
+ Contact.stubs(:new).with(contact_2_doc).returns(contact_2)
21
+
22
+ Contact.find_all_by_user_id('1').should == [user_1, user_2]
23
23
  end
24
24
 
25
25
  should "return a list of users for an authenticated user" do
26
26
  response = mock_request_cycle :for => 'contacts.getList', :with => {}
27
+ contact_1, contact_2 = [stub("contact"), stub('contact')]
27
28
  contact_1_doc, contact_2_doc = (response.body/'rsp/contacts/contact').to_a
28
29
 
29
30
  Contact.stubs(:new).with(contact_1_doc).returns(@contact_1)
@@ -34,7 +35,7 @@ module Fleakr::Objects
34
35
  end
35
36
 
36
37
  context "An instance of the Contact class" do
37
- context "when populating from an XML document" do
38
+ context "when populating from an XML document with public contacts" do
38
39
  setup do
39
40
  @object = Contact.new(Hpricot.XML(read_fixture('contacts.getPublicList')).at('contacts/contact'))
40
41
  end
@@ -45,6 +46,21 @@ module Fleakr::Objects
45
46
  should_have_a_value_for :icon_farm => '3'
46
47
 
47
48
  end
49
+
50
+ context "when populating from an XML document with authenticated user's contacts" do
51
+ setup do
52
+ @object = Contact.new(Hpricot.XML(read_fixture('contacts.getList')).at('contacts/contact'))
53
+ end
54
+
55
+ should_have_a_value_for :id => '9302864@N42'
56
+ should_have_a_value_for :username => 'blinky'
57
+ should_have_a_value_for :icon_server => '2263'
58
+ should_have_a_value_for :icon_farm => '3'
59
+ should_have_a_value_for :realname => 'Mr Blinky'
60
+ should_have_a_value_for :location => 'Middletown'
61
+
62
+ end
63
+
48
64
 
49
65
  context "in general" do
50
66
 
@@ -54,7 +70,7 @@ module Fleakr::Objects
54
70
 
55
71
  User.stubs(:new).returns(user)
56
72
 
57
- [:id, :username, :icon_server, :icon_farm].each do |method|
73
+ [:id, :username, :icon_server, :icon_farm, :realname, :location].each do |method|
58
74
  contact.stubs(method).with().returns(method.to_s)
59
75
  user.expects("#{method}=".to_sym).with(method.to_s)
60
76
  end
@@ -7,7 +7,7 @@ module Fleakr::Objects
7
7
 
8
8
  should_have_many :photos, :groups, :sets, :contacts, :tags
9
9
 
10
- should_autoload_when_accessing :name, :photos_url, :profile_url, :photos_count, :with => :load_info
10
+ should_autoload_when_accessing :name, :photos_url, :profile_url, :photos_count, :location, :with => :load_info
11
11
  should_autoload_when_accessing :icon_server, :icon_farm, :pro, :admin, :icon_url, :with => :load_info
12
12
 
13
13
  context "The User class" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: latompa-fleakr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Reagan