tagcrumbs 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/Manifest.txt +79 -56
- data/README.rdoc +9 -1
- data/Rakefile +2 -1
- data/TODO.txt +0 -7
- data/config/website.yml +2 -0
- data/examples/filter_new.rb +7 -3
- data/examples/placemark_new_suggestions.rb +4 -2
- data/examples/request_authorization.rb +1 -1
- data/examples/tagcrumbs_find.rb +3 -3
- data/examples/user.rb +1 -1
- data/lib/console.rb +14 -0
- data/lib/tagcrumbs.rb +41 -14
- data/lib/tagcrumbs/cli.rb +1 -1
- data/lib/tagcrumbs/config_store.rb +3 -3
- data/lib/tagcrumbs/core_extensions.rb +19 -0
- data/lib/tagcrumbs/parsers/json_parser.rb +7 -3
- data/lib/tagcrumbs/proxy.rb +6 -3
- data/lib/tagcrumbs/requestor.rb +22 -5
- data/lib/tagcrumbs/resources/{array.rb → collection.rb} +8 -7
- data/lib/tagcrumbs/resources/models/access_token.rb +8 -0
- data/lib/tagcrumbs/resources/models/accessors.rb +17 -3
- data/lib/tagcrumbs/resources/models/activity.rb +1 -0
- data/lib/tagcrumbs/resources/models/application.rb +9 -0
- data/lib/tagcrumbs/resources/models/comment.rb +2 -0
- data/lib/tagcrumbs/resources/models/email_recommendation.rb +17 -0
- data/lib/tagcrumbs/resources/models/favorite.rb +2 -1
- data/lib/tagcrumbs/resources/models/filter.rb +2 -2
- data/lib/tagcrumbs/resources/models/flag.rb +3 -0
- data/lib/tagcrumbs/resources/models/model.rb +8 -7
- data/lib/tagcrumbs/resources/models/paragraph.rb +8 -0
- data/lib/tagcrumbs/resources/models/picture.rb +4 -4
- data/lib/tagcrumbs/resources/models/place.rb +3 -3
- data/lib/tagcrumbs/resources/models/placemark.rb +3 -2
- data/lib/tagcrumbs/resources/models/profile.rb +0 -1
- data/lib/tagcrumbs/resources/models/profile_link.rb +1 -1
- data/lib/tagcrumbs/resources/models/root.rb +3 -3
- data/lib/tagcrumbs/resources/models/settings.rb +2 -1
- data/lib/tagcrumbs/resources/models/tagcrumb.rb +4 -12
- data/lib/tagcrumbs/resources/models/user.rb +27 -6
- data/lib/tagcrumbs/resources/models/user_recommendation.rb +1 -1
- data/lib/tagcrumbs/resources/resource.rb +4 -4
- data/script/console +8 -3
- data/spec/fixtures_external/README.rdoc +15 -0
- data/spec/fixtures_external/json/access_token.json +11 -0
- data/spec/{fixtures → fixtures_external/json}/activity.json +32 -25
- data/spec/{fixtures → fixtures_external/json}/address.json +22 -25
- data/spec/fixtures_external/json/application.json +13 -0
- data/spec/{fixtures → fixtures_external/json}/city.json +2 -11
- data/spec/{fixtures → fixtures_external/json}/comment.json +51 -44
- data/spec/{fixtures → fixtures_external/json}/country.json +1 -4
- data/spec/fixtures_external/json/email_recommendation.json +286 -0
- data/spec/{fixtures → fixtures_external/json}/fanship.json +30 -30
- data/spec/{fixtures → fixtures_external/json}/favorite.json +45 -47
- data/spec/{fixtures → fixtures_external/json}/filter.json +30 -42
- data/spec/{fixtures → fixtures_external/json}/friendship.json +30 -30
- data/spec/fixtures_external/json/geoname.json +18 -0
- data/spec/{fixtures → fixtures_external/json}/link.json +41 -44
- data/spec/{fixtures → fixtures_external/json}/location.json +21 -31
- data/spec/fixtures_external/json/paragraph.json +12 -0
- data/spec/fixtures_external/json/picture.json +129 -0
- data/spec/fixtures_external/json/picture_upload.json +9 -0
- data/spec/{fixtures → fixtures_external/json}/placemark.json +136 -142
- data/spec/fixtures_external/json/placemarks.json +851 -0
- data/spec/{fixtures → fixtures_external/json}/profile.json +65 -94
- data/spec/fixtures_external/json/profile_link.json +123 -0
- data/spec/{fixtures → fixtures_external/json}/root.json +17 -21
- data/spec/{fixtures → fixtures_external/json}/settings.json +26 -19
- data/spec/{fixtures → fixtures_external/json}/state.json +2 -8
- data/spec/{fixtures → fixtures_external/json}/subscription.json +41 -44
- data/spec/fixtures_external/json/suggestions.json +302 -0
- data/spec/{fixtures → fixtures_external/json}/tag.json +0 -0
- data/spec/{fixtures → fixtures_external/json}/user.json +44 -20
- data/spec/{fixtures → fixtures_external/json}/user_recommendation.json +52 -55
- data/spec/fixtures_external/json/validation_errors.json +6 -0
- data/spec/fixtures_external/kml/network_link.kml +24 -0
- data/spec/fixtures_external/kml/tagcrumbs.kml +64 -0
- data/spec/fixtures_external/rdf/placemark.rdf +56 -0
- data/spec/fixtures_external/rss/tagcrumbs.rss +24 -0
- data/spec/fixtures_external/xml/access_token.xml +5 -0
- data/spec/fixtures_external/xml/activity.xml +62 -0
- data/spec/fixtures_external/xml/address.xml +51 -0
- data/spec/fixtures_external/xml/application.xml +5 -0
- data/spec/fixtures_external/xml/city.xml +27 -0
- data/spec/fixtures_external/xml/comment.xml +81 -0
- data/spec/fixtures_external/xml/country.xml +10 -0
- data/spec/fixtures_external/xml/email_recommendation.xml +78 -0
- data/spec/fixtures_external/xml/fanship.xml +49 -0
- data/spec/fixtures_external/xml/favorite.xml +97 -0
- data/spec/fixtures_external/xml/filter.xml +68 -0
- data/spec/fixtures_external/xml/friendship.xml +49 -0
- data/spec/fixtures_external/xml/geoname.xml +6 -0
- data/spec/fixtures_external/xml/link.xml +78 -0
- data/spec/fixtures_external/xml/location.xml +58 -0
- data/spec/fixtures_external/xml/paragraph.xml +8 -0
- data/spec/fixtures_external/xml/picture.xml +36 -0
- data/spec/fixtures_external/xml/picture_upload.xml +153 -0
- data/spec/fixtures_external/xml/placemark.xml +54 -0
- data/spec/fixtures_external/xml/placemarks.xml +336 -0
- data/spec/fixtures_external/xml/profile.xml +77 -0
- data/spec/fixtures_external/xml/profile_link.xml +34 -0
- data/spec/fixtures_external/xml/root.xml +12 -0
- data/spec/fixtures_external/xml/settings.xml +42 -0
- data/spec/fixtures_external/xml/state.xml +19 -0
- data/spec/fixtures_external/xml/subscription.xml +76 -0
- data/spec/fixtures_external/xml/suggestions.xml +106 -0
- data/spec/{fixtures → fixtures_external/xml}/tag.xml +2 -2
- data/spec/fixtures_external/xml/user.xml +37 -0
- data/spec/fixtures_external/xml/user_recommendation.xml +94 -0
- data/spec/fixtures_external/xml/validation_errors.xml +5 -0
- data/spec/spec_helper.rb +12 -2
- data/spec/tagcrumbs/requestor_spec.rb +2 -2
- data/spec/tagcrumbs/resources/array_spec.rb +38 -38
- data/spec/tagcrumbs/resources/models/access_token_spec.rb +16 -0
- data/spec/tagcrumbs/resources/models/accessors_spec.rb +2 -2
- data/spec/tagcrumbs/resources/models/activity_spec.rb +5 -1
- data/spec/tagcrumbs/resources/models/address_spec.rb +1 -1
- data/spec/tagcrumbs/resources/models/application_spec.rb +17 -0
- data/spec/tagcrumbs/resources/models/city_spec.rb +2 -5
- data/spec/tagcrumbs/resources/models/comment_spec.rb +8 -2
- data/spec/tagcrumbs/resources/models/country_spec.rb +2 -4
- data/spec/tagcrumbs/resources/models/email_recommendation_spec.rb +31 -0
- data/spec/tagcrumbs/resources/models/fanship_spec.rb +1 -1
- data/spec/tagcrumbs/resources/models/favorite_spec.rb +5 -1
- data/spec/tagcrumbs/resources/models/filter_spec.rb +3 -4
- data/spec/tagcrumbs/resources/models/friendship_spec.rb +1 -1
- data/spec/tagcrumbs/resources/models/geoname_spec.rb +1 -1
- data/spec/tagcrumbs/resources/models/link_spec.rb +1 -1
- data/spec/tagcrumbs/resources/models/location_spec.rb +1 -1
- data/spec/tagcrumbs/resources/models/model_spec.rb +20 -3
- data/spec/tagcrumbs/resources/models/paragraph_spec.rb +21 -0
- data/spec/tagcrumbs/resources/models/picture_spec.rb +13 -21
- data/spec/tagcrumbs/resources/models/place_spec.rb +3 -3
- data/spec/tagcrumbs/resources/models/placemark_spec.rb +11 -9
- data/spec/tagcrumbs/resources/models/profile_link_spec.rb +6 -12
- data/spec/tagcrumbs/resources/models/profile_spec.rb +5 -12
- data/spec/tagcrumbs/resources/models/root_spec.rb +15 -19
- data/spec/tagcrumbs/resources/models/settings_spec.rb +3 -1
- data/spec/tagcrumbs/resources/models/state_spec.rb +2 -5
- data/spec/tagcrumbs/resources/models/subscription_spec.rb +1 -1
- data/spec/tagcrumbs/resources/models/suggestions_spec.rb +7 -7
- data/spec/tagcrumbs/resources/models/tag_spec.rb +1 -1
- data/spec/tagcrumbs/resources/models/tagcrumb_spec.rb +3 -11
- data/spec/tagcrumbs/resources/models/user_recommendation_spec.rb +1 -1
- data/spec/tagcrumbs/resources/models/user_spec.rb +35 -27
- data/spec/tagcrumbs/resources/resource_spec.rb +3 -3
- data/spec/tagcrumbs_spec.rb +7 -7
- data/tagcrumbs.gemspec +2 -2
- metadata +82 -58
- data/examples/tagcrumbs_search.rb +0 -7
- data/lib/tagcrumbs/validations.rb +0 -301
- data/spec/fixtures/activity.xml +0 -66
- data/spec/fixtures/address.xml +0 -58
- data/spec/fixtures/city.xml +0 -34
- data/spec/fixtures/comment.xml +0 -87
- data/spec/fixtures/country.xml +0 -13
- data/spec/fixtures/fanship.xml +0 -54
- data/spec/fixtures/favorite.xml +0 -109
- data/spec/fixtures/filter.xml +0 -80
- data/spec/fixtures/friendship.xml +0 -54
- data/spec/fixtures/geoname.json +0 -18
- data/spec/fixtures/geoname.xml +0 -6
- data/spec/fixtures/link.xml +0 -88
- data/spec/fixtures/location.xml +0 -71
- data/spec/fixtures/picture.json +0 -154
- data/spec/fixtures/picture.xml +0 -49
- data/spec/fixtures/placemark.xml +0 -58
- data/spec/fixtures/placemarks.json +0 -887
- data/spec/fixtures/placemarks.xml +0 -348
- data/spec/fixtures/profile.xml +0 -100
- data/spec/fixtures/profile_link.json +0 -156
- data/spec/fixtures/profile_link.xml +0 -49
- data/spec/fixtures/root.xml +0 -14
- data/spec/fixtures/settings.xml +0 -45
- data/spec/fixtures/state.xml +0 -23
- data/spec/fixtures/subscription.xml +0 -86
- data/spec/fixtures/suggestions.json +0 -1877
- data/spec/fixtures/suggestions.xml +0 -724
- data/spec/fixtures/user.xml +0 -31
- data/spec/fixtures/user_recommendation.xml +0 -106
- data/spec/fixtures/validation_errors.json +0 -5
- data/spec/fixtures/validation_errors.xml +0 -5
- data/spec/tagcrumbs/validations_spec.rb +0 -27
@@ -1,6 +1,11 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
class Tagcrumbs::ValidationTestModel < Tagcrumbs::Model
|
4
|
+
writeable_attributes :one, :two
|
5
|
+
|
6
|
+
end
|
7
|
+
|
8
|
+
describe Tagcrumbs::Model do
|
4
9
|
before(:each) do
|
5
10
|
@model = Tagcrumbs::Model.new
|
6
11
|
end
|
@@ -22,6 +27,18 @@ describe Tagcrumbs::Model do
|
|
22
27
|
|
23
28
|
|
24
29
|
describe "(Accessors)" do
|
25
|
-
|
30
|
+
it "should get error from document" do
|
31
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
32
|
+
model = Tagcrumbs::ValidationTestModel.new
|
33
|
+
|
34
|
+
model.errors_from_document(external_fixture_file('/validation_errors', format), format)
|
35
|
+
|
36
|
+
model.should_not be_valid
|
37
|
+
|
38
|
+
model.errors.size.should == 2
|
39
|
+
model.errors[0].should == "Latitude is not on this planet"
|
40
|
+
model.errors[1].should == "Name is already taken"
|
41
|
+
end
|
42
|
+
end
|
26
43
|
end
|
27
|
-
end
|
44
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::Paragraph do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
paragraph = Tagcrumbs::Paragraph.new_from_document(external_fixture_file("paragraph", format), format)
|
7
|
+
|
8
|
+
paragraph.resource_url.should be_blank
|
9
|
+
paragraph.new_record.should be_false
|
10
|
+
paragraph.loaded.should be_true
|
11
|
+
|
12
|
+
paragraph.heading.should == "HEADING"
|
13
|
+
|
14
|
+
paragraph.subparagraphs.should be_an_instance_of(Tagcrumbs::Collection)
|
15
|
+
paragraph.subparagraphs.size.should == 2
|
16
|
+
|
17
|
+
paragraph.subparagraphs[0].should == "SUBPARAGRAPH 1"
|
18
|
+
paragraph.subparagraphs[1].should == "SUBPARAGRAPH 2"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -3,31 +3,23 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
3
|
describe Tagcrumbs::Picture do
|
4
4
|
it "should create from a document" do
|
5
5
|
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
-
picture = Tagcrumbs::Picture.new_from_document(
|
6
|
+
picture = Tagcrumbs::Picture.new_from_document(external_fixture_file("picture", format), format)
|
7
7
|
|
8
8
|
picture.class.should == Tagcrumbs::Picture
|
9
9
|
picture.loaded?.should be_true
|
10
10
|
picture.resource_url.should == tagcrumbs_url('/sascha/profile/picture', format)
|
11
|
-
picture.
|
12
|
-
picture.small_thumbnail_url.should == "
|
13
|
-
picture.medium_thumbnail_url.should == "
|
11
|
+
picture.large_thumbnail_url.should == "http://s3.amazonaws.com/tagcrumbs_attachments_production/users/pictures/sascha/large.jpg?1246269353"
|
12
|
+
picture.small_thumbnail_url.should == "http://s3.amazonaws.com/tagcrumbs_attachments_production/users/pictures/sascha/small.jpg?1246269353"
|
13
|
+
picture.medium_thumbnail_url.should == "http://s3.amazonaws.com/tagcrumbs_attachments_production/users/pictures/sascha/medium.jpg?1246269353"
|
14
14
|
picture.content_type.should == "image/jpeg"
|
15
|
+
picture.created_at.should be_an_instance_of(Time)
|
16
|
+
picture.updated_at.should be_an_instance_of(Time)
|
15
17
|
|
16
|
-
picture.profile.resource_url.should == tagcrumbs_url('/sascha/profile', format)
|
17
|
-
picture.profile.new_record.should be_false
|
18
|
-
picture.profile.loaded.should be_true
|
19
|
-
|
20
|
-
picture.profile.fullname.should == "FULLNAME"
|
21
|
-
picture.profile.description.should == "DESCRIPTION"
|
22
|
-
picture.profile.about.should == "ABOUT"
|
23
|
-
picture.profile.created_at.should be_an_instance_of(Time)
|
24
|
-
picture.profile.updated_at.should be_an_instance_of(Time)
|
25
|
-
|
26
18
|
# has one associations
|
27
|
-
picture.
|
28
|
-
picture.
|
29
|
-
picture.
|
30
|
-
picture.
|
19
|
+
picture.user.class.should == Tagcrumbs::User
|
20
|
+
picture.user.loaded?.should be_true
|
21
|
+
picture.user.resource_url.should == tagcrumbs_url('/sascha', format)
|
22
|
+
picture.user.username.should == 'sascha'
|
31
23
|
end
|
32
24
|
end
|
33
25
|
|
@@ -35,8 +27,8 @@ describe Tagcrumbs::Picture do
|
|
35
27
|
@picture = Tagcrumbs::Picture.new
|
36
28
|
@picture.get_file(File.dirname(__FILE__) + '/../../../fixtures/picture.png')
|
37
29
|
|
38
|
-
@picture.
|
39
|
-
@picture.
|
40
|
-
@picture.
|
30
|
+
@picture.file[:filename].should == 'picture.png'
|
31
|
+
@picture.file[:mime_type].should == 'image/png'
|
32
|
+
@picture.file[:content].should be_present
|
41
33
|
end
|
42
34
|
end
|
@@ -2,11 +2,11 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
2
2
|
|
3
3
|
describe Tagcrumbs::Place do
|
4
4
|
it "should search for a place" do
|
5
|
-
stub_get('/index', 'root
|
6
|
-
stub_get('/places/search.xml?for=city&q=stuttgart', 'placemarks
|
5
|
+
stub_get('/index', 'root', :xml, [200])
|
6
|
+
stub_get('/places/search.xml?for=city&q=stuttgart', 'placemarks', :xml, [200]) # not correct result, but doesn't matter
|
7
7
|
|
8
8
|
places = Tagcrumbs::Place.search('stuttgart', :for => 'city')
|
9
9
|
|
10
|
-
places.should be_an_instance_of(Tagcrumbs::
|
10
|
+
places.should be_an_instance_of(Tagcrumbs::Collection)
|
11
11
|
end
|
12
12
|
end
|
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
3
|
describe Tagcrumbs::Placemark do
|
4
4
|
it "should create from a document" do
|
5
5
|
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
-
placemark = Tagcrumbs::Placemark.new_from_document(
|
6
|
+
placemark = Tagcrumbs::Placemark.new_from_document(external_fixture_file("placemark", format), format)
|
7
7
|
|
8
8
|
placemark.resource_url.should == tagcrumbs_url('/sascha/placemarks/placemark-name', format)
|
9
9
|
placemark.new_record.should be_false
|
@@ -31,24 +31,26 @@ describe Tagcrumbs::Placemark do
|
|
31
31
|
placemark.address.loaded?.should be_true
|
32
32
|
placemark.address.resource_url.should == tagcrumbs_url('/sascha/placemarks/placemark-name/address', format)
|
33
33
|
|
34
|
-
|
35
|
-
placemark.
|
36
|
-
placemark.
|
37
|
-
placemark.
|
34
|
+
placemark.application.class.should == Tagcrumbs::Application
|
35
|
+
placemark.application.loaded?.should be_true
|
36
|
+
placemark.application.name.should == "Tagcrumbs Gem"
|
37
|
+
placemark.application.url.should == "http://www.tagcrumbs.com"
|
38
38
|
|
39
|
-
|
39
|
+
# has many associations
|
40
|
+
|
41
|
+
placemark.comments.class.should == Tagcrumbs::Collection
|
40
42
|
placemark.comments.loaded?.should be_false
|
41
43
|
placemark.comments.resource_url.should == tagcrumbs_url('/sascha/placemarks/placemark-name/comments', format)
|
42
44
|
|
43
|
-
placemark.links.class.should == Tagcrumbs::
|
45
|
+
placemark.links.class.should == Tagcrumbs::Collection
|
44
46
|
placemark.links.loaded?.should be_false
|
45
47
|
placemark.links.resource_url.should == tagcrumbs_url('/sascha/placemarks/placemark-name/links', format)
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
49
51
|
it "should load suggestions" do
|
50
|
-
stub_get('/you', 'user
|
51
|
-
stub_get('/sascha/tagcrumbs/suggestions.xml?latitude=10&longitude=9', 'suggestions
|
52
|
+
stub_get('/you', 'user', :xml, [200])
|
53
|
+
stub_get('/sascha/tagcrumbs/suggestions.xml?latitude=10&longitude=9', 'suggestions', :xml, [200])
|
52
54
|
|
53
55
|
placemark = Tagcrumbs::Placemark.new(:latitude => 10, :longitude => 9)
|
54
56
|
suggestions = placemark.suggestions
|
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
3
|
describe Tagcrumbs::ProfileLink do
|
4
4
|
it "should create from a document" do
|
5
5
|
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
-
profile_link = Tagcrumbs::ProfileLink.new_from_document(
|
6
|
+
profile_link = Tagcrumbs::ProfileLink.new_from_document(external_fixture_file("profile_link", format), format)
|
7
7
|
|
8
8
|
profile_link.resource_url.should == tagcrumbs_url('/sascha/profile/links/1000042', format)
|
9
9
|
profile_link.new_record.should be_false
|
@@ -11,18 +11,12 @@ describe Tagcrumbs::ProfileLink do
|
|
11
11
|
|
12
12
|
profile_link.url.should == "http://www.test1.de"
|
13
13
|
profile_link.link_type.should == "Homepage"
|
14
|
-
|
15
|
-
profile_link.profile.fullname.should == "FULLNAME"
|
16
|
-
profile_link.profile.description.should == "DESCRIPTION"
|
17
|
-
profile_link.profile.about.should == "ABOUT"
|
18
|
-
profile_link.profile.created_at.should be_an_instance_of(Time)
|
19
|
-
profile_link.profile.updated_at.should be_an_instance_of(Time)
|
20
|
-
|
14
|
+
|
21
15
|
# has one associations
|
22
|
-
profile_link.
|
23
|
-
profile_link.
|
24
|
-
profile_link.
|
25
|
-
profile_link.
|
16
|
+
profile_link.user.class.should == Tagcrumbs::User
|
17
|
+
profile_link.user.loaded?.should be_true
|
18
|
+
profile_link.user.resource_url.should == tagcrumbs_url('/sascha', format)
|
19
|
+
profile_link.user.username.should == 'sascha'
|
26
20
|
|
27
21
|
end
|
28
22
|
end
|
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
3
|
describe Tagcrumbs::Profile do
|
4
4
|
it "should create from a document" do
|
5
5
|
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
-
profile = Tagcrumbs::Profile.new_from_document(
|
6
|
+
profile = Tagcrumbs::Profile.new_from_document(external_fixture_file("profile", format), format)
|
7
7
|
|
8
8
|
profile.resource_url.should == tagcrumbs_url('/sascha/profile', format)
|
9
9
|
profile.new_record.should be_false
|
@@ -21,19 +21,12 @@ describe Tagcrumbs::Profile do
|
|
21
21
|
profile.user.resource_url.should == tagcrumbs_url('/sascha', format)
|
22
22
|
profile.user.username.should == 'sascha'
|
23
23
|
|
24
|
-
profile.picture.class.should == Tagcrumbs::Picture
|
25
|
-
profile.picture.loaded?.should
|
26
|
-
|
27
|
-
profile.picture.url.should == "URL"
|
28
|
-
profile.picture.small_thumbnail_url.should == "SMALL THUMBNAIL URL"
|
29
|
-
profile.picture.medium_thumbnail_url.should == "MEDIUM THUMBNAIL URL"
|
30
|
-
profile.picture.content_type.should == "image/jpeg"
|
31
|
-
|
32
|
-
profile.picture.profile.class.should == Tagcrumbs::Profile
|
33
|
-
profile.picture.profile.loaded?.should be_false
|
24
|
+
profile.user.picture.class.should == Tagcrumbs::Picture
|
25
|
+
profile.user.picture.loaded?.should be_false
|
26
|
+
|
34
27
|
|
35
28
|
# has many associations
|
36
|
-
profile.profile_links.class.should == Tagcrumbs::
|
29
|
+
profile.profile_links.class.should == Tagcrumbs::Collection
|
37
30
|
profile.profile_links.loaded?.should be_true
|
38
31
|
profile.profile_links.size.should == 2
|
39
32
|
profile.profile_links[0].url.should == 'http://www.test1.de'
|
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
3
|
describe Tagcrumbs::Root do
|
4
4
|
it "should create from a document" do
|
5
5
|
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
-
root = Tagcrumbs::Root.new_from_document(
|
6
|
+
root = Tagcrumbs::Root.new_from_document(external_fixture_file("root", format), format)
|
7
7
|
|
8
8
|
root.resource_url.should == tagcrumbs_url("/?format=#{format}")
|
9
9
|
root.new_record.should be_false
|
@@ -14,44 +14,40 @@ describe Tagcrumbs::Root do
|
|
14
14
|
root.you.loaded?.should be_false
|
15
15
|
root.you.resource_url.should == tagcrumbs_url('/you', format)
|
16
16
|
|
17
|
-
|
18
|
-
root.location.loaded?.should be_false
|
19
|
-
root.location.resource_url.should == tagcrumbs_url('/location', format)
|
20
|
-
|
17
|
+
|
21
18
|
# has many
|
22
|
-
root.tagcrumbs.class.should == Tagcrumbs::
|
19
|
+
root.tagcrumbs.class.should == Tagcrumbs::Collection
|
23
20
|
root.tagcrumbs.loaded?.should be_false
|
24
21
|
root.tagcrumbs.resource_url.should == tagcrumbs_url('/tagcrumbs', format)
|
25
22
|
|
26
|
-
root.
|
27
|
-
root.nearby_tagcrumbs.loaded?.should be_false
|
28
|
-
root.nearby_tagcrumbs.resource_url.should == tagcrumbs_url('/nearby', format)
|
29
|
-
|
30
|
-
root.countries.class.should == Tagcrumbs::Array
|
23
|
+
root.countries.class.should == Tagcrumbs::Collection
|
31
24
|
root.countries.loaded?.should be_false
|
32
25
|
root.countries.resource_url.should == tagcrumbs_url('/places', format)
|
33
26
|
|
34
|
-
root.popular_countries.class.should == Tagcrumbs::
|
27
|
+
root.popular_countries.class.should == Tagcrumbs::Collection
|
35
28
|
root.popular_countries.loaded?.should be_false
|
36
29
|
root.popular_countries.resource_url.should == tagcrumbs_url('/popular/places', format)
|
37
30
|
|
38
|
-
root.place_search.class.should == Tagcrumbs::
|
31
|
+
root.place_search.class.should == Tagcrumbs::Collection
|
39
32
|
root.place_search.loaded?.should be_false
|
40
33
|
root.place_search.resource_url.should == tagcrumbs_url('/places/search', format)
|
41
34
|
|
42
35
|
|
43
|
-
root.tags.class.should == Tagcrumbs::
|
36
|
+
root.tags.class.should == Tagcrumbs::Collection
|
44
37
|
root.tags.loaded?.should be_false
|
45
38
|
root.tags.resource_url.should == tagcrumbs_url('/tags', format)
|
46
39
|
|
47
|
-
root.users.class.should == Tagcrumbs::
|
40
|
+
root.users.class.should == Tagcrumbs::Collection
|
48
41
|
root.users.loaded?.should be_false
|
49
42
|
root.users.resource_url.should == tagcrumbs_url('/users', format)
|
43
|
+
|
44
|
+
root.privacy_policy.class.should == Tagcrumbs::Collection
|
45
|
+
root.privacy_policy.loaded?.should be_false
|
46
|
+
root.privacy_policy.resource_url.should == tagcrumbs_url('/privacy', format)
|
50
47
|
|
51
|
-
root.
|
52
|
-
root.
|
53
|
-
root.
|
54
|
-
|
48
|
+
root.terms_and_conditions.class.should == Tagcrumbs::Collection
|
49
|
+
root.terms_and_conditions.loaded?.should be_false
|
50
|
+
root.terms_and_conditions.resource_url.should == tagcrumbs_url('/terms', format)
|
55
51
|
end
|
56
52
|
end
|
57
53
|
end
|
@@ -3,16 +3,18 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
3
|
describe Tagcrumbs::Settings do
|
4
4
|
it "should create from a document" do
|
5
5
|
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
-
settings = Tagcrumbs::Settings.new_from_document(
|
6
|
+
settings = Tagcrumbs::Settings.new_from_document(external_fixture_file("settings", format), format)
|
7
7
|
|
8
8
|
settings.resource_url.should == tagcrumbs_url('/sascha/settings', format)
|
9
9
|
settings.new_record.should be_false
|
10
10
|
settings.loaded.should be_true
|
11
11
|
|
12
12
|
settings.locale.should == 'de-DE'
|
13
|
+
settings.timezone.should == 'Berlin'
|
13
14
|
settings.unit_system.should == 'imperial'
|
14
15
|
settings.notification_recommendation.should be_true
|
15
16
|
settings.notification_fan.should be_true
|
17
|
+
settings.notification_subscription.should be_true
|
16
18
|
settings.newsletter.should be_false
|
17
19
|
settings.facebook_new_placemark_feed.should be_true
|
18
20
|
settings.facebook_new_comment_feed.should be_true
|
@@ -3,24 +3,21 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
3
|
describe Tagcrumbs::State do
|
4
4
|
it "should create from a document" do
|
5
5
|
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
-
state = Tagcrumbs::State.new_from_document(
|
6
|
+
state = Tagcrumbs::State.new_from_document(external_fixture_file("state", format), format)
|
7
7
|
|
8
8
|
state.resource_url.should == tagcrumbs_url('/places/germany/states/land-baden-w%C3%BCrttemberg', format)
|
9
9
|
state.new_record.should be_false
|
10
10
|
state.loaded.should be_true
|
11
11
|
|
12
12
|
state.name.should == 'Land Baden-Württemberg'
|
13
|
-
state.permalink.should == 'land-baden-württemberg'
|
14
13
|
|
15
14
|
state.country.name.should == 'Deutschland'
|
16
|
-
|
17
|
-
state.country.permalink.should == 'germany'
|
18
15
|
|
19
16
|
state.country.geoname.class.should == Tagcrumbs::Geoname
|
20
17
|
state.country.geoname.loaded?.should be_true
|
21
18
|
state.country.geoname.resource_url.should == "http://www.geonames.org/2921044"
|
22
19
|
|
23
|
-
state.country.states.class.should == Tagcrumbs::
|
20
|
+
state.country.states.class.should == Tagcrumbs::Collection
|
24
21
|
state.country.states.loaded?.should be_false
|
25
22
|
state.country.states.resource_url.should == tagcrumbs_url('/places/germany/states', format)
|
26
23
|
|
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
3
|
describe Tagcrumbs::Subscription do
|
4
4
|
it "should create from a document" do
|
5
5
|
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
-
subscription = Tagcrumbs::Subscription.new_from_document(
|
6
|
+
subscription = Tagcrumbs::Subscription.new_from_document(external_fixture_file("subscription", format), format)
|
7
7
|
|
8
8
|
subscription.resource_url.should == tagcrumbs_url('/sascha/subscriptions/1', format)
|
9
9
|
subscription.new_record.should be_false
|
@@ -3,25 +3,25 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
3
|
describe Tagcrumbs::Suggestions do
|
4
4
|
it "should create from a document" do
|
5
5
|
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
-
suggestions = Tagcrumbs::Suggestions.new_from_document(
|
6
|
+
suggestions = Tagcrumbs::Suggestions.new_from_document(external_fixture_file("suggestions", format), format)
|
7
7
|
|
8
8
|
suggestions.resource_url.should == tagcrumbs_url('/sascha/tagcrumbs/suggestions', format)
|
9
9
|
suggestions.new_record.should be_false
|
10
10
|
suggestions.loaded.should be_true
|
11
11
|
|
12
|
-
suggestions.cities.class.should == Tagcrumbs::
|
13
|
-
suggestions.cities.size.should ==
|
14
|
-
suggestions.cities[0].name == '
|
12
|
+
suggestions.cities.class.should == Tagcrumbs::Collection
|
13
|
+
suggestions.cities.size.should == 3
|
14
|
+
suggestions.cities[0].name.should == 'Hohenhaslach'
|
15
15
|
|
16
|
-
suggestions.popular_tags.class.should == Tagcrumbs::
|
16
|
+
suggestions.popular_tags.class.should == Tagcrumbs::Collection
|
17
17
|
suggestions.popular_tags.size.should == 2
|
18
18
|
suggestions.popular_tags[0].name.should == 'tag1'
|
19
19
|
|
20
|
-
suggestions.recommended_tags.class.should == Tagcrumbs::
|
20
|
+
suggestions.recommended_tags.class.should == Tagcrumbs::Collection
|
21
21
|
suggestions.recommended_tags.size.should == 2
|
22
22
|
suggestions.recommended_tags[0].name.should == 'tag3'
|
23
23
|
|
24
|
-
suggestions.names.class.should == Tagcrumbs::
|
24
|
+
suggestions.names.class.should == Tagcrumbs::Collection
|
25
25
|
suggestions.names.size.should == 3
|
26
26
|
suggestions.names[0] == 'name1'
|
27
27
|
suggestions.names[1] == 'name2'
|
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
3
|
describe Tagcrumbs::Tag do
|
4
4
|
it "should create from a document" do
|
5
5
|
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
-
tag = Tagcrumbs::Tag.new_from_document(
|
6
|
+
tag = Tagcrumbs::Tag.new_from_document(external_fixture_file("tag", format), format)
|
7
7
|
|
8
8
|
tag.resource_url.should == tagcrumbs_url('/tags/tag1', format)
|
9
9
|
tag.new_record.should be_false
|
@@ -2,20 +2,12 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
2
2
|
|
3
3
|
describe Tagcrumbs::Tagcrumb do
|
4
4
|
it "should find Tagcrumbs" do
|
5
|
-
stub_get('/index', 'root
|
6
|
-
stub_get("/tagcrumbs.xml?tagcrumb_type=Favorite", 'placemarks
|
5
|
+
stub_get('/index', 'root', :xml, [200])
|
6
|
+
stub_get("/tagcrumbs.xml?tagcrumb_type=Favorite", 'placemarks', :xml, [200])
|
7
7
|
|
8
8
|
placemarks = Tagcrumbs::Tagcrumb.find(:tagcrumb_type => :favorite)
|
9
9
|
|
10
|
-
placemarks.should be_an_instance_of(Tagcrumbs::
|
10
|
+
placemarks.should be_an_instance_of(Tagcrumbs::Collection)
|
11
11
|
end
|
12
12
|
|
13
|
-
it "should search Tagcrumbs" do
|
14
|
-
stub_get('/index', 'root.xml', [200])
|
15
|
-
stub_get('/search.xml?q=test', 'placemarks.xml', [200])
|
16
|
-
|
17
|
-
placemarks = Tagcrumbs::Tagcrumb.search(:q => 'test')
|
18
|
-
|
19
|
-
placemarks.should be_an_instance_of(Tagcrumbs::Array)
|
20
|
-
end
|
21
13
|
end
|
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
3
|
describe Tagcrumbs::UserRecommendation do
|
4
4
|
it "should create from a document" do
|
5
5
|
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
-
user_recommendation = Tagcrumbs::UserRecommendation.new_from_document(
|
6
|
+
user_recommendation = Tagcrumbs::UserRecommendation.new_from_document(external_fixture_file("user_recommendation", format), format)
|
7
7
|
|
8
8
|
user_recommendation.resource_url.should == tagcrumbs_url('/sascha/recommendations/70', format)
|
9
9
|
user_recommendation.new_record.should be_false
|
@@ -3,13 +3,14 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
3
|
describe Tagcrumbs::User do
|
4
4
|
it "should create from a document" do
|
5
5
|
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
-
user = Tagcrumbs::User.new_from_document(
|
6
|
+
user = Tagcrumbs::User.new_from_document(external_fixture_file("user", format), format)
|
7
7
|
|
8
8
|
user.resource_url.should == tagcrumbs_url('/sascha', format)
|
9
9
|
user.new_record.should be_false
|
10
10
|
user.loaded.should be_true
|
11
11
|
|
12
12
|
user.username.should == 'sascha'
|
13
|
+
user.facebook_uid.should == 1234
|
13
14
|
user.created_at.should be_an_instance_of(Time)
|
14
15
|
|
15
16
|
# has one associations
|
@@ -30,97 +31,104 @@ describe Tagcrumbs::User do
|
|
30
31
|
user.suggestions.resource_url.should == tagcrumbs_url('/sascha/tagcrumbs/suggestions', format)
|
31
32
|
|
32
33
|
user.picture.class.should == Tagcrumbs::Picture
|
33
|
-
user.picture.loaded?.should
|
34
|
+
user.picture.loaded?.should be_true
|
34
35
|
user.picture.resource_url.should == tagcrumbs_url('/sascha/profile/picture', format)
|
36
|
+
|
37
|
+
user.picture.large_thumbnail_url.should == "http://s3.amazonaws.com/tagcrumbs_attachments_production/users/pictures/sascha/large.jpg?1246269353"
|
38
|
+
user.picture.small_thumbnail_url.should == "http://s3.amazonaws.com/tagcrumbs_attachments_production/users/pictures/sascha/small.jpg?1246269353"
|
39
|
+
user.picture.medium_thumbnail_url.should == "http://s3.amazonaws.com/tagcrumbs_attachments_production/users/pictures/sascha/medium.jpg?1246269353"
|
40
|
+
user.picture.content_type.should == "image/jpeg"
|
41
|
+
user.picture.created_at.should be_an_instance_of(Time)
|
42
|
+
user.picture.updated_at.should be_an_instance_of(Time)
|
35
43
|
|
36
44
|
# has many associations
|
37
|
-
user.filters.class.should == Tagcrumbs::
|
45
|
+
user.filters.class.should == Tagcrumbs::Collection
|
38
46
|
user.filters.loaded?.should be_false
|
39
47
|
user.filters.resource_url.should == tagcrumbs_url('/sascha/filters', format)
|
40
48
|
|
41
|
-
user.comments.class.should == Tagcrumbs::
|
49
|
+
user.comments.class.should == Tagcrumbs::Collection
|
42
50
|
user.comments.loaded?.should be_false
|
43
51
|
user.comments.resource_url.should == tagcrumbs_url('/sascha/comments', format)
|
44
52
|
|
45
|
-
user.recommendations.class.should == Tagcrumbs::
|
53
|
+
user.recommendations.class.should == Tagcrumbs::Collection
|
46
54
|
user.recommendations.loaded?.should be_false
|
47
55
|
user.recommendations.resource_url.should == tagcrumbs_url('/sascha/recommendations', format)
|
48
56
|
|
49
|
-
user.received_recommendations.class.should == Tagcrumbs::
|
57
|
+
user.received_recommendations.class.should == Tagcrumbs::Collection
|
50
58
|
user.received_recommendations.loaded?.should be_false
|
51
|
-
user.received_recommendations.resource_url.should == tagcrumbs_url('/sascha/
|
59
|
+
user.received_recommendations.resource_url.should == tagcrumbs_url('/sascha/received_recommendations', format)
|
52
60
|
|
53
|
-
user.profile_links.class.should == Tagcrumbs::
|
61
|
+
user.profile_links.class.should == Tagcrumbs::Collection
|
54
62
|
user.profile_links.loaded?.should be_false
|
55
63
|
user.profile_links.resource_url.should == tagcrumbs_url('/sascha/profile/links', format)
|
56
64
|
|
57
|
-
user.tagcrumbs.class.should == Tagcrumbs::
|
65
|
+
user.tagcrumbs.class.should == Tagcrumbs::Collection
|
58
66
|
user.tagcrumbs.loaded?.should be_false
|
59
67
|
user.tagcrumbs.resource_url.should == tagcrumbs_url('/sascha/tagcrumbs', format)
|
60
68
|
|
61
|
-
user.placemarks.class.should == Tagcrumbs::
|
69
|
+
user.placemarks.class.should == Tagcrumbs::Collection
|
62
70
|
user.placemarks.loaded?.should be_false
|
63
71
|
user.placemarks.resource_url.should == tagcrumbs_url('/sascha/placemarks', format)
|
64
72
|
|
65
|
-
user.favorites.class.should == Tagcrumbs::
|
73
|
+
user.favorites.class.should == Tagcrumbs::Collection
|
66
74
|
user.favorites.loaded?.should be_false
|
67
75
|
user.favorites.resource_url.should == tagcrumbs_url('/sascha/favorites', format)
|
68
76
|
|
69
|
-
user.activities.class.should == Tagcrumbs::
|
77
|
+
user.activities.class.should == Tagcrumbs::Collection
|
70
78
|
user.activities.loaded?.should be_false
|
71
79
|
user.activities.resource_url.should == tagcrumbs_url('/sascha/activities', format)
|
72
80
|
|
73
|
-
user.tags.class.should == Tagcrumbs::
|
81
|
+
user.tags.class.should == Tagcrumbs::Collection
|
74
82
|
user.tags.loaded?.should be_false
|
75
83
|
user.tags.resource_url.should == tagcrumbs_url('/sascha/tags', format)
|
76
84
|
|
77
|
-
user.places.class.should == Tagcrumbs::
|
85
|
+
user.places.class.should == Tagcrumbs::Collection
|
78
86
|
user.places.loaded?.should be_false
|
79
87
|
user.places.resource_url.should == tagcrumbs_url('/sascha/places', format)
|
80
88
|
|
81
|
-
user.friendships.class.should == Tagcrumbs::
|
89
|
+
user.friendships.class.should == Tagcrumbs::Collection
|
82
90
|
user.friendships.loaded?.should be_false
|
83
91
|
user.friendships.resource_url.should == tagcrumbs_url('/sascha/friends', format)
|
84
92
|
|
85
|
-
user.fanships.class.should == Tagcrumbs::
|
93
|
+
user.fanships.class.should == Tagcrumbs::Collection
|
86
94
|
user.fanships.loaded?.should be_false
|
87
95
|
user.fanships.resource_url.should == tagcrumbs_url('/sascha/fans', format)
|
88
96
|
|
89
|
-
user.tagcrumbs_friends.class.should == Tagcrumbs::
|
97
|
+
user.tagcrumbs_friends.class.should == Tagcrumbs::Collection
|
90
98
|
user.tagcrumbs_friends.loaded?.should be_false
|
91
99
|
user.tagcrumbs_friends.resource_url.should == tagcrumbs_url('/sascha/friends/tagcrumbs', format)
|
92
100
|
|
93
|
-
user.tagcrumbs_fans.class.should == Tagcrumbs::
|
101
|
+
user.tagcrumbs_fans.class.should == Tagcrumbs::Collection
|
94
102
|
user.tagcrumbs_fans.loaded?.should be_false
|
95
103
|
user.tagcrumbs_fans.resource_url.should == tagcrumbs_url('/sascha/fans/tagcrumbs', format)
|
96
104
|
end
|
97
105
|
end
|
98
106
|
|
99
107
|
it "should search users" do
|
100
|
-
stub_get('/index', 'root
|
101
|
-
stub_get('/users.xml?
|
108
|
+
stub_get('/index', 'root', :xml, [200])
|
109
|
+
stub_get('/users.xml?q=sascha', 'placemarks', :xml, [200]) # not correct result, but doesn't matter
|
102
110
|
|
103
|
-
users = Tagcrumbs::User.search('sascha')
|
111
|
+
users = Tagcrumbs::User.search(:q => 'sascha')
|
104
112
|
|
105
|
-
users.should be_an_instance_of(Tagcrumbs::
|
113
|
+
users.should be_an_instance_of(Tagcrumbs::Collection)
|
106
114
|
end
|
107
115
|
|
108
116
|
it "should find by username" do
|
109
|
-
stub_get('/peter', 'user
|
117
|
+
stub_get('/peter', 'user', :xml, [200])
|
110
118
|
|
111
119
|
Tagcrumbs::User.find_by_username('peter')
|
112
120
|
end
|
113
121
|
|
114
122
|
it "should find the friendship with another user" do
|
115
|
-
stub_get('/you', 'user
|
116
|
-
stub_get('/sascha/friends/peter', 'friendship
|
123
|
+
stub_get('/you', 'user', :xml, [200])
|
124
|
+
stub_get('/sascha/friends/peter', 'friendship', :xml, [200])
|
117
125
|
|
118
126
|
Tagcrumbs.current_user.friendship_with('peter')
|
119
127
|
end
|
120
128
|
|
121
129
|
it "should find the fanship with another user" do
|
122
|
-
stub_get('/you', 'user
|
123
|
-
stub_get('/sascha/fans/peter', 'fanship
|
130
|
+
stub_get('/you', 'user', :xml, [200])
|
131
|
+
stub_get('/sascha/fans/peter', 'fanship', :xml, [200])
|
124
132
|
|
125
133
|
Tagcrumbs.current_user.fanship_with('peter')
|
126
134
|
end
|