tagcrumbs-tagcrumbs 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +9 -0
- data/License.txt +22 -0
- data/Manifest.txt +177 -0
- data/PostInstall.txt +2 -0
- data/README.rdoc +45 -0
- data/Rakefile +35 -0
- data/TODO.txt +17 -0
- data/bin/tagcrumbs +5 -0
- data/examples/address_update.rb +15 -0
- data/examples/comment_new.rb +19 -0
- data/examples/favorite_new.rb +17 -0
- data/examples/filter_new.rb +15 -0
- data/examples/friendship_create.rb +19 -0
- data/examples/link_new.rb +16 -0
- data/examples/location_update.rb +16 -0
- data/examples/picture_update.rb +16 -0
- data/examples/placemark_new_simple.rb +24 -0
- data/examples/placemark_new_suggestions.rb +24 -0
- data/examples/profile_link_new.rb +14 -0
- data/examples/profile_update.rb +12 -0
- data/examples/request_authorization.rb +25 -0
- data/examples/settings_update.rb +12 -0
- data/examples/subscription_new.rb +15 -0
- data/examples/tagcrumbs_find.rb +25 -0
- data/examples/tagcrumbs_search.rb +7 -0
- data/examples/user.rb +28 -0
- data/examples/user_recommendation_new.rb +15 -0
- data/lib/tagcrumbs.rb +232 -0
- data/lib/tagcrumbs/builders/builder.rb +45 -0
- data/lib/tagcrumbs/builders/json_builder.rb +38 -0
- data/lib/tagcrumbs/builders/xml_builder.rb +30 -0
- data/lib/tagcrumbs/cli.rb +268 -0
- data/lib/tagcrumbs/config_store.rb +35 -0
- data/lib/tagcrumbs/exceptions.rb +13 -0
- data/lib/tagcrumbs/node.rb +43 -0
- data/lib/tagcrumbs/parsers/json_parser.rb +79 -0
- data/lib/tagcrumbs/parsers/parser.rb +24 -0
- data/lib/tagcrumbs/parsers/xml_parser.rb +54 -0
- data/lib/tagcrumbs/proxy.rb +32 -0
- data/lib/tagcrumbs/requestor.rb +140 -0
- data/lib/tagcrumbs/resources/array.rb +108 -0
- data/lib/tagcrumbs/resources/models/accessors.rb +252 -0
- data/lib/tagcrumbs/resources/models/activity.rb +19 -0
- data/lib/tagcrumbs/resources/models/address.rb +16 -0
- data/lib/tagcrumbs/resources/models/city.rb +13 -0
- data/lib/tagcrumbs/resources/models/comment.rb +12 -0
- data/lib/tagcrumbs/resources/models/country.rb +15 -0
- data/lib/tagcrumbs/resources/models/fanship.rb +12 -0
- data/lib/tagcrumbs/resources/models/favorite.rb +22 -0
- data/lib/tagcrumbs/resources/models/filter.rb +32 -0
- data/lib/tagcrumbs/resources/models/flag.rb +10 -0
- data/lib/tagcrumbs/resources/models/friendship.rb +12 -0
- data/lib/tagcrumbs/resources/models/geoname.rb +8 -0
- data/lib/tagcrumbs/resources/models/link.rb +13 -0
- data/lib/tagcrumbs/resources/models/location.rb +13 -0
- data/lib/tagcrumbs/resources/models/model.rb +148 -0
- data/lib/tagcrumbs/resources/models/picture.rb +28 -0
- data/lib/tagcrumbs/resources/models/place.rb +17 -0
- data/lib/tagcrumbs/resources/models/placemark.rb +30 -0
- data/lib/tagcrumbs/resources/models/profile.rb +16 -0
- data/lib/tagcrumbs/resources/models/profile_link.rb +12 -0
- data/lib/tagcrumbs/resources/models/root.rb +19 -0
- data/lib/tagcrumbs/resources/models/settings.rb +14 -0
- data/lib/tagcrumbs/resources/models/state.rb +14 -0
- data/lib/tagcrumbs/resources/models/subscription.rb +13 -0
- data/lib/tagcrumbs/resources/models/suggestions.rb +11 -0
- data/lib/tagcrumbs/resources/models/tag.rb +6 -0
- data/lib/tagcrumbs/resources/models/tagcrumb.rb +58 -0
- data/lib/tagcrumbs/resources/models/user.rb +101 -0
- data/lib/tagcrumbs/resources/models/user_recommendation.rb +18 -0
- data/lib/tagcrumbs/resources/resource.rb +76 -0
- data/lib/tagcrumbs/validations.rb +301 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/fixtures/activity.json +210 -0
- data/spec/fixtures/activity.xml +66 -0
- data/spec/fixtures/address.json +183 -0
- data/spec/fixtures/address.xml +58 -0
- data/spec/fixtures/city.json +88 -0
- data/spec/fixtures/city.xml +34 -0
- data/spec/fixtures/comment.json +286 -0
- data/spec/fixtures/comment.xml +87 -0
- data/spec/fixtures/country.json +32 -0
- data/spec/fixtures/country.xml +13 -0
- data/spec/fixtures/fanship.json +180 -0
- data/spec/fixtures/fanship.xml +54 -0
- data/spec/fixtures/favorite.json +332 -0
- data/spec/fixtures/favorite.xml +109 -0
- data/spec/fixtures/filter.json +243 -0
- data/spec/fixtures/filter.xml +80 -0
- data/spec/fixtures/friendship.json +180 -0
- data/spec/fixtures/friendship.xml +54 -0
- data/spec/fixtures/geoname.json +18 -0
- data/spec/fixtures/geoname.xml +6 -0
- data/spec/fixtures/json_parser.json +25 -0
- data/spec/fixtures/link.json +288 -0
- data/spec/fixtures/link.xml +88 -0
- data/spec/fixtures/location.json +204 -0
- data/spec/fixtures/location.xml +71 -0
- data/spec/fixtures/picture.json +154 -0
- data/spec/fixtures/picture.png +0 -0
- data/spec/fixtures/picture.xml +49 -0
- data/spec/fixtures/placemark.json +357 -0
- data/spec/fixtures/placemark.xml +58 -0
- data/spec/fixtures/placemarks.json +887 -0
- data/spec/fixtures/placemarks.xml +348 -0
- data/spec/fixtures/profile.json +282 -0
- data/spec/fixtures/profile.xml +100 -0
- data/spec/fixtures/profile_link.json +156 -0
- data/spec/fixtures/profile_link.xml +49 -0
- data/spec/fixtures/root.json +46 -0
- data/spec/fixtures/root.xml +14 -0
- data/spec/fixtures/settings.json +147 -0
- data/spec/fixtures/settings.xml +45 -0
- data/spec/fixtures/state.json +62 -0
- data/spec/fixtures/state.xml +23 -0
- data/spec/fixtures/subscription.json +283 -0
- data/spec/fixtures/subscription.xml +86 -0
- data/spec/fixtures/suggestions.json +1877 -0
- data/spec/fixtures/suggestions.xml +724 -0
- data/spec/fixtures/tag.json +9 -0
- data/spec/fixtures/tag.xml +4 -0
- data/spec/fixtures/user.json +105 -0
- data/spec/fixtures/user.xml +31 -0
- data/spec/fixtures/user_recommendation.json +349 -0
- data/spec/fixtures/user_recommendation.xml +106 -0
- data/spec/fixtures/validation_errors.json +5 -0
- data/spec/fixtures/validation_errors.xml +5 -0
- data/spec/fixtures/xml_parser.xml +13 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +75 -0
- data/spec/tagcrumbs/builders/builder_spec.rb +57 -0
- data/spec/tagcrumbs/builders/json_builder_spec.rb +47 -0
- data/spec/tagcrumbs/builders/xml_builder_spec.rb +34 -0
- data/spec/tagcrumbs/exceptions_spec.rb +16 -0
- data/spec/tagcrumbs/node_spec.rb +42 -0
- data/spec/tagcrumbs/parsers/json_parser_spec.rb +117 -0
- data/spec/tagcrumbs/parsers/parser_spec.rb +25 -0
- data/spec/tagcrumbs/parsers/xml_parser_spec.rb +117 -0
- data/spec/tagcrumbs/proxy_spec.rb +48 -0
- data/spec/tagcrumbs/requestor_spec.rb +62 -0
- data/spec/tagcrumbs/resources/array_spec.rb +62 -0
- data/spec/tagcrumbs/resources/models/accessors_spec.rb +123 -0
- data/spec/tagcrumbs/resources/models/activity_spec.rb +33 -0
- data/spec/tagcrumbs/resources/models/address_spec.rb +24 -0
- data/spec/tagcrumbs/resources/models/city_spec.rb +33 -0
- data/spec/tagcrumbs/resources/models/comment_spec.rb +23 -0
- data/spec/tagcrumbs/resources/models/country_spec.rb +26 -0
- data/spec/tagcrumbs/resources/models/fanship_spec.rb +28 -0
- data/spec/tagcrumbs/resources/models/favorite_spec.rb +28 -0
- data/spec/tagcrumbs/resources/models/filter_spec.rb +43 -0
- data/spec/tagcrumbs/resources/models/flag_spec.rb +5 -0
- data/spec/tagcrumbs/resources/models/friendship_spec.rb +28 -0
- data/spec/tagcrumbs/resources/models/geoname_spec.rb +18 -0
- data/spec/tagcrumbs/resources/models/link_spec.rb +24 -0
- data/spec/tagcrumbs/resources/models/location_spec.rb +28 -0
- data/spec/tagcrumbs/resources/models/model_spec.rb +27 -0
- data/spec/tagcrumbs/resources/models/picture_spec.rb +42 -0
- data/spec/tagcrumbs/resources/models/place_spec.rb +12 -0
- data/spec/tagcrumbs/resources/models/placemark_spec.rb +61 -0
- data/spec/tagcrumbs/resources/models/profile_link_spec.rb +29 -0
- data/spec/tagcrumbs/resources/models/profile_spec.rb +43 -0
- data/spec/tagcrumbs/resources/models/root_spec.rb +57 -0
- data/spec/tagcrumbs/resources/models/settings_spec.rb +32 -0
- data/spec/tagcrumbs/resources/models/state_spec.rb +30 -0
- data/spec/tagcrumbs/resources/models/subscription_spec.rb +28 -0
- data/spec/tagcrumbs/resources/models/suggestions_spec.rb +33 -0
- data/spec/tagcrumbs/resources/models/tag_spec.rb +16 -0
- data/spec/tagcrumbs/resources/models/tagcrumb_spec.rb +21 -0
- data/spec/tagcrumbs/resources/models/user_recommendation_spec.rb +35 -0
- data/spec/tagcrumbs/resources/models/user_spec.rb +128 -0
- data/spec/tagcrumbs/resources/resource_spec.rb +62 -0
- data/spec/tagcrumbs/validations_spec.rb +27 -0
- data/spec/tagcrumbs_spec.rb +103 -0
- data/tagcrumbs.gemspec +59 -0
- data/tasks/rspec.rake +21 -0
- metadata +325 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::ProfileLink do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
profile_link = Tagcrumbs::ProfileLink.new_from_document(fixture_file("profile_link", format), format)
|
7
|
+
|
8
|
+
profile_link.resource_url.should == tagcrumbs_url('/sascha/profile/links/1000042', format)
|
9
|
+
profile_link.new_record.should be_false
|
10
|
+
profile_link.loaded.should be_true
|
11
|
+
|
12
|
+
profile_link.url.should == "http://www.test1.de"
|
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
|
+
|
21
|
+
# has one associations
|
22
|
+
profile_link.profile.user.class.should == Tagcrumbs::User
|
23
|
+
profile_link.profile.user.loaded?.should be_true
|
24
|
+
profile_link.profile.user.resource_url.should == tagcrumbs_url('/sascha', format)
|
25
|
+
profile_link.profile.user.username.should == 'sascha'
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::Profile do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
profile = Tagcrumbs::Profile.new_from_document(fixture_file("profile", format), format)
|
7
|
+
|
8
|
+
profile.resource_url.should == tagcrumbs_url('/sascha/profile', format)
|
9
|
+
profile.new_record.should be_false
|
10
|
+
profile.loaded.should be_true
|
11
|
+
|
12
|
+
profile.fullname.should == "FULLNAME"
|
13
|
+
profile.description.should == "DESCRIPTION"
|
14
|
+
profile.about.should == "ABOUT"
|
15
|
+
profile.created_at.should be_an_instance_of(Time)
|
16
|
+
profile.updated_at.should be_an_instance_of(Time)
|
17
|
+
|
18
|
+
# has one associations
|
19
|
+
profile.user.class.should == Tagcrumbs::User
|
20
|
+
profile.user.loaded?.should be_true
|
21
|
+
profile.user.resource_url.should == tagcrumbs_url('/sascha', format)
|
22
|
+
profile.user.username.should == 'sascha'
|
23
|
+
|
24
|
+
profile.picture.class.should == Tagcrumbs::Picture
|
25
|
+
profile.picture.loaded?.should be_true
|
26
|
+
profile.picture.resource_url.should == tagcrumbs_url('/sascha/profile/picture', format)
|
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
|
34
|
+
|
35
|
+
# has many associations
|
36
|
+
profile.profile_links.class.should == Tagcrumbs::Array
|
37
|
+
profile.profile_links.loaded?.should be_true
|
38
|
+
profile.profile_links.size.should == 2
|
39
|
+
profile.profile_links[0].url.should == 'http://www.test1.de'
|
40
|
+
profile.profile_links[1].url.should == 'http://www.test2.de'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::Root do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
root = Tagcrumbs::Root.new_from_document(fixture_file("root", format), format)
|
7
|
+
|
8
|
+
root.resource_url.should == tagcrumbs_url("/?format=#{format}")
|
9
|
+
root.new_record.should be_false
|
10
|
+
root.loaded.should be_true
|
11
|
+
|
12
|
+
# has one
|
13
|
+
root.you.class.should == Tagcrumbs::User
|
14
|
+
root.you.loaded?.should be_false
|
15
|
+
root.you.resource_url.should == tagcrumbs_url('/you', format)
|
16
|
+
|
17
|
+
root.location.class.should == Tagcrumbs::Location
|
18
|
+
root.location.loaded?.should be_false
|
19
|
+
root.location.resource_url.should == tagcrumbs_url('/location', format)
|
20
|
+
|
21
|
+
# has many
|
22
|
+
root.tagcrumbs.class.should == Tagcrumbs::Array
|
23
|
+
root.tagcrumbs.loaded?.should be_false
|
24
|
+
root.tagcrumbs.resource_url.should == tagcrumbs_url('/tagcrumbs', format)
|
25
|
+
|
26
|
+
root.nearby_tagcrumbs.class.should == Tagcrumbs::Array
|
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
|
31
|
+
root.countries.loaded?.should be_false
|
32
|
+
root.countries.resource_url.should == tagcrumbs_url('/places', format)
|
33
|
+
|
34
|
+
root.popular_countries.class.should == Tagcrumbs::Array
|
35
|
+
root.popular_countries.loaded?.should be_false
|
36
|
+
root.popular_countries.resource_url.should == tagcrumbs_url('/popular/places', format)
|
37
|
+
|
38
|
+
root.place_search.class.should == Tagcrumbs::Array
|
39
|
+
root.place_search.loaded?.should be_false
|
40
|
+
root.place_search.resource_url.should == tagcrumbs_url('/places/search', format)
|
41
|
+
|
42
|
+
|
43
|
+
root.tags.class.should == Tagcrumbs::Array
|
44
|
+
root.tags.loaded?.should be_false
|
45
|
+
root.tags.resource_url.should == tagcrumbs_url('/tags', format)
|
46
|
+
|
47
|
+
root.users.class.should == Tagcrumbs::Array
|
48
|
+
root.users.loaded?.should be_false
|
49
|
+
root.users.resource_url.should == tagcrumbs_url('/users', format)
|
50
|
+
|
51
|
+
root.search.class.should == Tagcrumbs::Array
|
52
|
+
root.search.loaded?.should be_false
|
53
|
+
root.search.resource_url.should == tagcrumbs_url('/search', format)
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::Settings do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
settings = Tagcrumbs::Settings.new_from_document(fixture_file("settings", format), format)
|
7
|
+
|
8
|
+
settings.resource_url.should == tagcrumbs_url('/sascha/settings', format)
|
9
|
+
settings.new_record.should be_false
|
10
|
+
settings.loaded.should be_true
|
11
|
+
|
12
|
+
settings.locale.should == 'de-DE'
|
13
|
+
settings.unit_system.should == 'imperial'
|
14
|
+
settings.notification_recommendation.should be_true
|
15
|
+
settings.notification_fan.should be_true
|
16
|
+
settings.newsletter.should be_false
|
17
|
+
settings.facebook_new_placemark_feed.should be_true
|
18
|
+
settings.facebook_new_comment_feed.should be_true
|
19
|
+
settings.facebook_new_favorite_feed.should be_true
|
20
|
+
|
21
|
+
settings.created_at.should be_an_instance_of(Time)
|
22
|
+
settings.updated_at.should be_an_instance_of(Time)
|
23
|
+
|
24
|
+
# has one associations
|
25
|
+
settings.user.class.should == Tagcrumbs::User
|
26
|
+
settings.user.loaded?.should be_true
|
27
|
+
settings.user.resource_url.should == tagcrumbs_url('/sascha', format)
|
28
|
+
settings.user.username.should == 'sascha'
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::State do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
state = Tagcrumbs::State.new_from_document(fixture_file("state", format), format)
|
7
|
+
|
8
|
+
state.resource_url.should == tagcrumbs_url('/places/germany/states/land-baden-w%C3%BCrttemberg', format)
|
9
|
+
state.new_record.should be_false
|
10
|
+
state.loaded.should be_true
|
11
|
+
|
12
|
+
state.name.should == 'Land Baden-Württemberg'
|
13
|
+
state.permalink.should == 'land-baden-württemberg'
|
14
|
+
|
15
|
+
state.country.name.should == 'Deutschland'
|
16
|
+
|
17
|
+
state.country.permalink.should == 'germany'
|
18
|
+
|
19
|
+
state.country.geoname.class.should == Tagcrumbs::Geoname
|
20
|
+
state.country.geoname.loaded?.should be_true
|
21
|
+
state.country.geoname.resource_url.should == "http://www.geonames.org/2921044"
|
22
|
+
|
23
|
+
state.country.states.class.should == Tagcrumbs::Array
|
24
|
+
state.country.states.loaded?.should be_false
|
25
|
+
state.country.states.resource_url.should == tagcrumbs_url('/places/germany/states', format)
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::Subscription do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
subscription = Tagcrumbs::Subscription.new_from_document(fixture_file("subscription", format), format)
|
7
|
+
|
8
|
+
subscription.resource_url.should == tagcrumbs_url('/sascha/subscriptions/1', format)
|
9
|
+
subscription.new_record.should be_false
|
10
|
+
subscription.loaded.should be_true
|
11
|
+
|
12
|
+
subscription.created_at.should be_an_instance_of(Time)
|
13
|
+
subscription.updated_at.should be_an_instance_of(Time)
|
14
|
+
|
15
|
+
# has one associations
|
16
|
+
subscription.tagcrumb.class.should == Tagcrumbs::Placemark
|
17
|
+
subscription.tagcrumb.loaded?.should be_true
|
18
|
+
subscription.tagcrumb.resource_url.should == tagcrumbs_url('/sascha/placemarks/placemark-name', format)
|
19
|
+
subscription.tagcrumb.name.should == 'PLACEMARK NAME'
|
20
|
+
|
21
|
+
subscription.user.class.should == Tagcrumbs::User
|
22
|
+
subscription.user.loaded?.should be_true
|
23
|
+
subscription.user.resource_url.should == tagcrumbs_url('/sascha', format)
|
24
|
+
subscription.user.username.should == 'sascha'
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::Suggestions do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
suggestions = Tagcrumbs::Suggestions.new_from_document(fixture_file("suggestions", format), format)
|
7
|
+
|
8
|
+
suggestions.resource_url.should == tagcrumbs_url('/sascha/tagcrumbs/suggestions', format)
|
9
|
+
suggestions.new_record.should be_false
|
10
|
+
suggestions.loaded.should be_true
|
11
|
+
|
12
|
+
suggestions.cities.class.should == Tagcrumbs::Array
|
13
|
+
suggestions.cities.size.should == 21
|
14
|
+
suggestions.cities[0].name == 'Laim'
|
15
|
+
|
16
|
+
suggestions.popular_tags.class.should == Tagcrumbs::Array
|
17
|
+
suggestions.popular_tags.size.should == 2
|
18
|
+
suggestions.popular_tags[0].name.should == 'tag1'
|
19
|
+
|
20
|
+
suggestions.recommended_tags.class.should == Tagcrumbs::Array
|
21
|
+
suggestions.recommended_tags.size.should == 2
|
22
|
+
suggestions.recommended_tags[0].name.should == 'tag3'
|
23
|
+
|
24
|
+
suggestions.names.class.should == Tagcrumbs::Array
|
25
|
+
suggestions.names.size.should == 3
|
26
|
+
suggestions.names[0] == 'name1'
|
27
|
+
suggestions.names[1] == 'name2'
|
28
|
+
suggestions.names[2] == 'name3'
|
29
|
+
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::Tag do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
tag = Tagcrumbs::Tag.new_from_document(fixture_file("tag", format), format)
|
7
|
+
|
8
|
+
tag.resource_url.should == tagcrumbs_url('/tags/tag1', format)
|
9
|
+
tag.new_record.should be_false
|
10
|
+
tag.loaded.should be_true
|
11
|
+
|
12
|
+
tag.name.should == "tag1"
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::Tagcrumb do
|
4
|
+
it "should find Tagcrumbs" do
|
5
|
+
stub_get('/index', 'root.xml', [200])
|
6
|
+
stub_get("/tagcrumbs.xml?tagcrumb_type=Favorite", 'placemarks.xml', [200])
|
7
|
+
|
8
|
+
placemarks = Tagcrumbs::Tagcrumb.find(:tagcrumb_type => :favorite)
|
9
|
+
|
10
|
+
placemarks.should be_an_instance_of(Tagcrumbs::Array)
|
11
|
+
end
|
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
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::UserRecommendation do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
user_recommendation = Tagcrumbs::UserRecommendation.new_from_document(fixture_file("user_recommendation", format), format)
|
7
|
+
|
8
|
+
user_recommendation.resource_url.should == tagcrumbs_url('/sascha/recommendations/70', format)
|
9
|
+
user_recommendation.new_record.should be_false
|
10
|
+
user_recommendation.loaded.should be_true
|
11
|
+
|
12
|
+
user_recommendation.message.should == "MESSAGE"
|
13
|
+
user_recommendation.created_at.should be_an_instance_of(Time)
|
14
|
+
user_recommendation.updated_at.should be_an_instance_of(Time)
|
15
|
+
|
16
|
+
# has one associations
|
17
|
+
user_recommendation.tagcrumb.class.should == Tagcrumbs::Placemark
|
18
|
+
user_recommendation.tagcrumb.loaded?.should be_true
|
19
|
+
user_recommendation.tagcrumb.resource_url.should == tagcrumbs_url('/sascha/placemarks/placemark-name', format)
|
20
|
+
user_recommendation.tagcrumb.name.should == 'PLACEMARK NAME'
|
21
|
+
|
22
|
+
user_recommendation.user.class.should == Tagcrumbs::User
|
23
|
+
user_recommendation.user.loaded?.should be_true
|
24
|
+
user_recommendation.user.resource_url.should == tagcrumbs_url('/sascha', format)
|
25
|
+
user_recommendation.user.username.should == 'sascha'
|
26
|
+
|
27
|
+
user_recommendation.recommended_user.class.should == Tagcrumbs::User
|
28
|
+
user_recommendation.recommended_user.loaded?.should be_true
|
29
|
+
user_recommendation.recommended_user.resource_url.should == tagcrumbs_url('/peter', format)
|
30
|
+
user_recommendation.recommended_user.username.should == 'peter'
|
31
|
+
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::User do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
user = Tagcrumbs::User.new_from_document(fixture_file("user", format), format)
|
7
|
+
|
8
|
+
user.resource_url.should == tagcrumbs_url('/sascha', format)
|
9
|
+
user.new_record.should be_false
|
10
|
+
user.loaded.should be_true
|
11
|
+
|
12
|
+
user.username.should == 'sascha'
|
13
|
+
user.created_at.should be_an_instance_of(Time)
|
14
|
+
|
15
|
+
# has one associations
|
16
|
+
user.profile.class.should == Tagcrumbs::Profile
|
17
|
+
user.profile.loaded?.should be_false
|
18
|
+
user.profile.resource_url.should == tagcrumbs_url('/sascha/profile', format)
|
19
|
+
|
20
|
+
user.settings.class.should == Tagcrumbs::Settings
|
21
|
+
user.settings.loaded?.should be_false
|
22
|
+
user.settings.resource_url.should == tagcrumbs_url('/sascha/settings', format)
|
23
|
+
|
24
|
+
user.location.class.should == Tagcrumbs::Location
|
25
|
+
user.location.loaded?.should be_false
|
26
|
+
user.location.resource_url.should == tagcrumbs_url('/location', format)
|
27
|
+
|
28
|
+
user.suggestions.class.should == Tagcrumbs::Suggestions
|
29
|
+
user.suggestions.loaded?.should be_false
|
30
|
+
user.suggestions.resource_url.should == tagcrumbs_url('/sascha/tagcrumbs/suggestions', format)
|
31
|
+
|
32
|
+
user.picture.class.should == Tagcrumbs::Picture
|
33
|
+
user.picture.loaded?.should be_false
|
34
|
+
user.picture.resource_url.should == tagcrumbs_url('/sascha/profile/picture', format)
|
35
|
+
|
36
|
+
# has many associations
|
37
|
+
user.filters.class.should == Tagcrumbs::Array
|
38
|
+
user.filters.loaded?.should be_false
|
39
|
+
user.filters.resource_url.should == tagcrumbs_url('/sascha/filters', format)
|
40
|
+
|
41
|
+
user.comments.class.should == Tagcrumbs::Array
|
42
|
+
user.comments.loaded?.should be_false
|
43
|
+
user.comments.resource_url.should == tagcrumbs_url('/sascha/comments', format)
|
44
|
+
|
45
|
+
user.recommendations.class.should == Tagcrumbs::Array
|
46
|
+
user.recommendations.loaded?.should be_false
|
47
|
+
user.recommendations.resource_url.should == tagcrumbs_url('/sascha/recommendations', format)
|
48
|
+
|
49
|
+
user.received_recommendations.class.should == Tagcrumbs::Array
|
50
|
+
user.received_recommendations.loaded?.should be_false
|
51
|
+
user.received_recommendations.resource_url.should == tagcrumbs_url('/sascha/recommendations/received', format)
|
52
|
+
|
53
|
+
user.profile_links.class.should == Tagcrumbs::Array
|
54
|
+
user.profile_links.loaded?.should be_false
|
55
|
+
user.profile_links.resource_url.should == tagcrumbs_url('/sascha/profile/links', format)
|
56
|
+
|
57
|
+
user.tagcrumbs.class.should == Tagcrumbs::Array
|
58
|
+
user.tagcrumbs.loaded?.should be_false
|
59
|
+
user.tagcrumbs.resource_url.should == tagcrumbs_url('/sascha/tagcrumbs', format)
|
60
|
+
|
61
|
+
user.placemarks.class.should == Tagcrumbs::Array
|
62
|
+
user.placemarks.loaded?.should be_false
|
63
|
+
user.placemarks.resource_url.should == tagcrumbs_url('/sascha/placemarks', format)
|
64
|
+
|
65
|
+
user.favorites.class.should == Tagcrumbs::Array
|
66
|
+
user.favorites.loaded?.should be_false
|
67
|
+
user.favorites.resource_url.should == tagcrumbs_url('/sascha/favorites', format)
|
68
|
+
|
69
|
+
user.activities.class.should == Tagcrumbs::Array
|
70
|
+
user.activities.loaded?.should be_false
|
71
|
+
user.activities.resource_url.should == tagcrumbs_url('/sascha/activities', format)
|
72
|
+
|
73
|
+
user.tags.class.should == Tagcrumbs::Array
|
74
|
+
user.tags.loaded?.should be_false
|
75
|
+
user.tags.resource_url.should == tagcrumbs_url('/sascha/tags', format)
|
76
|
+
|
77
|
+
user.places.class.should == Tagcrumbs::Array
|
78
|
+
user.places.loaded?.should be_false
|
79
|
+
user.places.resource_url.should == tagcrumbs_url('/sascha/places', format)
|
80
|
+
|
81
|
+
user.friendships.class.should == Tagcrumbs::Array
|
82
|
+
user.friendships.loaded?.should be_false
|
83
|
+
user.friendships.resource_url.should == tagcrumbs_url('/sascha/friends', format)
|
84
|
+
|
85
|
+
user.fanships.class.should == Tagcrumbs::Array
|
86
|
+
user.fanships.loaded?.should be_false
|
87
|
+
user.fanships.resource_url.should == tagcrumbs_url('/sascha/fans', format)
|
88
|
+
|
89
|
+
user.tagcrumbs_friends.class.should == Tagcrumbs::Array
|
90
|
+
user.tagcrumbs_friends.loaded?.should be_false
|
91
|
+
user.tagcrumbs_friends.resource_url.should == tagcrumbs_url('/sascha/friends/tagcrumbs', format)
|
92
|
+
|
93
|
+
user.tagcrumbs_fans.class.should == Tagcrumbs::Array
|
94
|
+
user.tagcrumbs_fans.loaded?.should be_false
|
95
|
+
user.tagcrumbs_fans.resource_url.should == tagcrumbs_url('/sascha/fans/tagcrumbs', format)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should search users" do
|
100
|
+
stub_get('/index', 'root.xml', [200])
|
101
|
+
stub_get('/users.xml?u=sascha', 'placemarks.xml', [200]) # not correct result, but doesn't matter
|
102
|
+
|
103
|
+
users = Tagcrumbs::User.search('sascha')
|
104
|
+
|
105
|
+
users.should be_an_instance_of(Tagcrumbs::Array)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should find by username" do
|
109
|
+
stub_get('/peter', 'user.xml', [200])
|
110
|
+
|
111
|
+
Tagcrumbs::User.find_by_username('peter')
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should find the friendship with another user" do
|
115
|
+
stub_get('/you', 'user.xml', [200])
|
116
|
+
stub_get('/sascha/friends/peter', 'friendship.xml', [200])
|
117
|
+
|
118
|
+
Tagcrumbs.current_user.friendship_with('peter')
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should find the fanship with another user" do
|
122
|
+
stub_get('/you', 'user.xml', [200])
|
123
|
+
stub_get('/sascha/fans/peter', 'fanship.xml', [200])
|
124
|
+
|
125
|
+
Tagcrumbs.current_user.fanship_with('peter')
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|