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,24 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::Address do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
address = Tagcrumbs::Address.new_from_document(fixture_file("address", format), format)
|
7
|
+
|
8
|
+
address.resource_url.should == tagcrumbs_url('/sascha/placemarks/placemark-name/address', format)
|
9
|
+
address.new_record.should be_false
|
10
|
+
address.loaded.should be_true
|
11
|
+
|
12
|
+
address.street_address.should == "STREET ADDRESS"
|
13
|
+
address.postal_code.should == "POSTAL CODE"
|
14
|
+
address.city.should == "CITY"
|
15
|
+
address.state.should == "STATE"
|
16
|
+
address.country.should == "COUNTRY"
|
17
|
+
|
18
|
+
# has one associations
|
19
|
+
address.tagcrumb.class.should == Tagcrumbs::Placemark
|
20
|
+
address.tagcrumb.loaded?.should be_true
|
21
|
+
address.tagcrumb.resource_url.should == tagcrumbs_url('/sascha/placemarks/placemark-name', format)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::City do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
city = Tagcrumbs::City.new_from_document(fixture_file("city", format), format)
|
7
|
+
|
8
|
+
city.resource_url.should == tagcrumbs_url('/places/germany/states/land-baden-w%C3%BCrttemberg/cities/stuttgart', format)
|
9
|
+
city.name.should == 'Stuttgart'
|
10
|
+
city.permalink.should == 'stuttgart'
|
11
|
+
|
12
|
+
city.state.resource_url.should == tagcrumbs_url('/places/germany/states/land-baden-w%C3%BCrttemberg', format)
|
13
|
+
city.state.new_record.should be_false
|
14
|
+
city.state.loaded.should be_true
|
15
|
+
|
16
|
+
city.state.name.should == 'Land Baden-Württemberg'
|
17
|
+
city.state.permalink.should == 'land-baden-württemberg'
|
18
|
+
|
19
|
+
city.state.country.name.should == 'Deutschland'
|
20
|
+
|
21
|
+
city.state.country.permalink.should == 'germany'
|
22
|
+
|
23
|
+
city.state.country.geoname.class.should == Tagcrumbs::Geoname
|
24
|
+
city.state.country.geoname.loaded?.should be_true
|
25
|
+
city.state.country.geoname.resource_url.should == "http://www.geonames.org/2921044"
|
26
|
+
|
27
|
+
city.state.country.states.class.should == Tagcrumbs::Array
|
28
|
+
city.state.country.states.loaded?.should be_false
|
29
|
+
city.state.country.states.resource_url.should == tagcrumbs_url('/places/germany/states', format)
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::Comment do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
comment = Tagcrumbs::Comment.new_from_document(fixture_file("comment", format), format)
|
7
|
+
|
8
|
+
comment.resource_url.should == tagcrumbs_url('/sascha/comments/84', format)
|
9
|
+
comment.new_record.should be_false
|
10
|
+
comment.loaded.should be_true
|
11
|
+
|
12
|
+
comment.text.should == "COMMENT TEXT"
|
13
|
+
comment.created_at.should be_an_instance_of(Time)
|
14
|
+
comment.updated_at.should be_an_instance_of(Time)
|
15
|
+
|
16
|
+
# has one associations
|
17
|
+
comment.tagcrumb.class.should == Tagcrumbs::Placemark
|
18
|
+
comment.tagcrumb.loaded?.should be_true
|
19
|
+
comment.tagcrumb.resource_url.should == tagcrumbs_url('/sascha/placemarks/placemark-name', format)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::Country do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
country = Tagcrumbs::Country.new_from_document(fixture_file("country", format), format)
|
7
|
+
|
8
|
+
country.resource_url.should == tagcrumbs_url('/places/germany', format)
|
9
|
+
country.new_record.should be_false
|
10
|
+
country.loaded.should be_true
|
11
|
+
|
12
|
+
country.name.should == 'Deutschland'
|
13
|
+
|
14
|
+
country.permalink.should == 'germany'
|
15
|
+
|
16
|
+
country.geoname.class.should == Tagcrumbs::Geoname
|
17
|
+
country.geoname.loaded?.should be_true
|
18
|
+
country.geoname.resource_url.should == "http://www.geonames.org/2921044"
|
19
|
+
|
20
|
+
country.states.class.should == Tagcrumbs::Array
|
21
|
+
country.states.loaded?.should be_false
|
22
|
+
country.states.resource_url.should == tagcrumbs_url('/places/germany/states', format)
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::Fanship do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
fanship = Tagcrumbs::Fanship.new_from_document(fixture_file("fanship", format), format)
|
7
|
+
|
8
|
+
fanship.resource_url.should == tagcrumbs_url('/sascha/fans/peter', format)
|
9
|
+
fanship.new_record.should be_false
|
10
|
+
fanship.loaded.should be_true
|
11
|
+
|
12
|
+
fanship.created_at.should be_an_instance_of(Time)
|
13
|
+
fanship.updated_at.should be_an_instance_of(Time)
|
14
|
+
|
15
|
+
# has one associations
|
16
|
+
fanship.user.class.should == Tagcrumbs::User
|
17
|
+
fanship.user.loaded?.should be_true
|
18
|
+
fanship.user.resource_url.should == tagcrumbs_url('/sascha', format)
|
19
|
+
fanship.user.username.should == 'sascha'
|
20
|
+
|
21
|
+
fanship.fan.class.should == Tagcrumbs::User
|
22
|
+
fanship.fan.loaded?.should be_true
|
23
|
+
fanship.fan.resource_url.should == tagcrumbs_url('/peter', format)
|
24
|
+
fanship.fan.username.should == 'peter'
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::Favorite do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
favorite = Tagcrumbs::Favorite.new_from_document(fixture_file("favorite", format), format)
|
7
|
+
|
8
|
+
favorite.resource_url.should == tagcrumbs_url('/sascha/favorites/1002145', format)
|
9
|
+
favorite.new_record.should be_false
|
10
|
+
favorite.loaded.should be_true
|
11
|
+
|
12
|
+
favorite.created_at.should be_an_instance_of(Time)
|
13
|
+
favorite.updated_at.should be_an_instance_of(Time)
|
14
|
+
|
15
|
+
# has one associations
|
16
|
+
favorite.tagcrumb.class.should == Tagcrumbs::Placemark
|
17
|
+
favorite.tagcrumb.loaded?.should be_true
|
18
|
+
favorite.tagcrumb.resource_url.should == tagcrumbs_url('/peter/placemarks/placemark-name-2', format)
|
19
|
+
favorite.tagcrumb.name.should == 'PLACEMARK NAME 2'
|
20
|
+
|
21
|
+
favorite.user.class.should == Tagcrumbs::User
|
22
|
+
favorite.user.loaded?.should be_true
|
23
|
+
favorite.user.resource_url.should == tagcrumbs_url('/sascha', format)
|
24
|
+
favorite.user.username.should == 'sascha'
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::Filter do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
filter = Tagcrumbs::Filter.new_from_document(fixture_file("filter", format), format)
|
7
|
+
|
8
|
+
filter.resource_url.should == tagcrumbs_url('/sascha/filters/filter-name', format)
|
9
|
+
filter.new_record.should be_false
|
10
|
+
filter.loaded.should be_true
|
11
|
+
|
12
|
+
filter.name.should == "FILTER NAME"
|
13
|
+
filter.permalink.should == 'filter-name'
|
14
|
+
filter.private.should be_false
|
15
|
+
filter.tagcrumb_type.should be_nil
|
16
|
+
|
17
|
+
filter.tag_list.should be_blank
|
18
|
+
filter.middle_of_nowhere.should be_nil
|
19
|
+
filter.since.should be_an_instance_of(Time)
|
20
|
+
filter.until.should be_an_instance_of(Time)
|
21
|
+
filter.from.should == 'everybody'
|
22
|
+
filter.within.should be_nil
|
23
|
+
|
24
|
+
filter.created_at.should be_an_instance_of(Time)
|
25
|
+
filter.updated_at.should be_an_instance_of(Time)
|
26
|
+
|
27
|
+
# has one associations
|
28
|
+
filter.user.class.should == Tagcrumbs::User
|
29
|
+
filter.user.loaded?.should be_true
|
30
|
+
filter.user.resource_url.should == tagcrumbs_url('/sascha', format)
|
31
|
+
filter.user.username.should == 'sascha'
|
32
|
+
|
33
|
+
filter.city.class.should == Tagcrumbs::City
|
34
|
+
filter.city.loaded?.should be_true
|
35
|
+
filter.city.name.should == 'Berlin'
|
36
|
+
|
37
|
+
filter.tagcrumbs.class.should == Tagcrumbs::Array
|
38
|
+
filter.tagcrumbs.loaded?.should be_false
|
39
|
+
filter.tagcrumbs.resource_url.should == tagcrumbs_url('/sascha/filters/filter-name/tagcrumbs', format)
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::Friendship do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
friendship = Tagcrumbs::Friendship.new_from_document(fixture_file("friendship", format), format)
|
7
|
+
|
8
|
+
friendship.resource_url.should == tagcrumbs_url('/sascha/friends/peter', format)
|
9
|
+
friendship.new_record.should be_false
|
10
|
+
friendship.loaded.should be_true
|
11
|
+
|
12
|
+
friendship.created_at.should be_an_instance_of(Time)
|
13
|
+
friendship.updated_at.should be_an_instance_of(Time)
|
14
|
+
|
15
|
+
# has one associations
|
16
|
+
friendship.user.class.should == Tagcrumbs::User
|
17
|
+
friendship.user.loaded?.should be_true
|
18
|
+
friendship.user.resource_url.should == tagcrumbs_url('/sascha', format)
|
19
|
+
friendship.user.username.should == 'sascha'
|
20
|
+
|
21
|
+
friendship.friend.class.should == Tagcrumbs::User
|
22
|
+
friendship.friend.loaded?.should be_true
|
23
|
+
friendship.friend.resource_url.should == tagcrumbs_url('/peter', format)
|
24
|
+
friendship.friend.username.should == 'peter'
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::Geoname do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
geoname = Tagcrumbs::Geoname.new_from_document(fixture_file("geoname", format), format)
|
7
|
+
|
8
|
+
geoname.resource_url.should == "http://www.geonames.org/2921044"
|
9
|
+
geoname.new_record.should be_false
|
10
|
+
geoname.loaded.should be_true
|
11
|
+
|
12
|
+
geoname.geonameid.should == 2921044
|
13
|
+
geoname.latitude.should == 51.5
|
14
|
+
geoname.longitude.should == 10.5
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::Link do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
link = Tagcrumbs::Link.new_from_document(fixture_file("link", format), format)
|
7
|
+
|
8
|
+
link.resource_url.should == tagcrumbs_url('/sascha/links/1000104', format)
|
9
|
+
link.new_record.should be_false
|
10
|
+
link.loaded.should be_true
|
11
|
+
|
12
|
+
link.url.should == "http://www.test.de"
|
13
|
+
link.title.should == "test.de"
|
14
|
+
link.created_at.should be_an_instance_of(Time)
|
15
|
+
link.updated_at.should be_an_instance_of(Time)
|
16
|
+
|
17
|
+
# has one associations
|
18
|
+
link.tagcrumb.class.should == Tagcrumbs::Placemark
|
19
|
+
link.tagcrumb.loaded?.should be_true
|
20
|
+
link.tagcrumb.resource_url.should == tagcrumbs_url('/sascha/placemarks/placemark-name', format)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::Location do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
location = Tagcrumbs::Location.new_from_document(fixture_file("location", format), format)
|
7
|
+
|
8
|
+
location.resource_url.should == tagcrumbs_url('/location', format)
|
9
|
+
location.new_record.should be_false
|
10
|
+
location.loaded.should be_true
|
11
|
+
|
12
|
+
location.latitude.should == 48.1344468066674
|
13
|
+
location.longitude.should == 11.5754914283752
|
14
|
+
|
15
|
+
# has one associations
|
16
|
+
location.user.class.should == Tagcrumbs::User
|
17
|
+
location.user.loaded?.should be_true
|
18
|
+
location.user.resource_url.should == tagcrumbs_url('/sascha', format)
|
19
|
+
location.user.username.should == 'sascha'
|
20
|
+
|
21
|
+
location.city.class.should == Tagcrumbs::City
|
22
|
+
location.city.loaded?.should be_true
|
23
|
+
location.city.resource_url.should == tagcrumbs_url('http://www.tagcrumbs.com/places/germany/states/freistaat-bayern/cities/munich', format)
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::Model do
|
4
|
+
before(:each) do
|
5
|
+
@model = Tagcrumbs::Model.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should reset" do
|
9
|
+
@model.properties = {1 => 2}
|
10
|
+
@model.resource_url = 'test.de'
|
11
|
+
@model.loaded = true
|
12
|
+
@model.new_record = false
|
13
|
+
|
14
|
+
@model.reset!
|
15
|
+
|
16
|
+
@model.properties.should == {}
|
17
|
+
@model.resource_url.should be_nil
|
18
|
+
@model.loaded.should be_false
|
19
|
+
@model.new_record.should be_true
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
describe "(Accessors)" do
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::Picture do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
picture = Tagcrumbs::Picture.new_from_document(fixture_file("picture", format), format)
|
7
|
+
|
8
|
+
picture.class.should == Tagcrumbs::Picture
|
9
|
+
picture.loaded?.should be_true
|
10
|
+
picture.resource_url.should == tagcrumbs_url('/sascha/profile/picture', format)
|
11
|
+
picture.url.should == "URL"
|
12
|
+
picture.small_thumbnail_url.should == "SMALL THUMBNAIL URL"
|
13
|
+
picture.medium_thumbnail_url.should == "MEDIUM THUMBNAIL URL"
|
14
|
+
picture.content_type.should == "image/jpeg"
|
15
|
+
|
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
|
+
# has one associations
|
27
|
+
picture.profile.user.class.should == Tagcrumbs::User
|
28
|
+
picture.profile.user.loaded?.should be_true
|
29
|
+
picture.profile.user.resource_url.should == tagcrumbs_url('/sascha', format)
|
30
|
+
picture.profile.user.username.should == 'sascha'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should get a local file" do
|
35
|
+
@picture = Tagcrumbs::Picture.new
|
36
|
+
@picture.get_file(File.dirname(__FILE__) + '/../../../fixtures/picture.png')
|
37
|
+
|
38
|
+
@picture.picture_file[:filename].should == 'picture.png'
|
39
|
+
@picture.picture_file[:mime_type].should == 'image/png'
|
40
|
+
@picture.picture_file[:content].should be_present
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::Place do
|
4
|
+
it "should search for a place" do
|
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
|
+
|
8
|
+
places = Tagcrumbs::Place.search('stuttgart', :for => 'city')
|
9
|
+
|
10
|
+
places.should be_an_instance_of(Tagcrumbs::Array)
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Tagcrumbs::Placemark do
|
4
|
+
it "should create from a document" do
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
6
|
+
placemark = Tagcrumbs::Placemark.new_from_document(fixture_file("placemark", format), format)
|
7
|
+
|
8
|
+
placemark.resource_url.should == tagcrumbs_url('/sascha/placemarks/placemark-name', format)
|
9
|
+
placemark.new_record.should be_false
|
10
|
+
placemark.loaded.should be_true
|
11
|
+
|
12
|
+
placemark.name.should == "PLACEMARK NAME"
|
13
|
+
placemark.notes.should == "PLACEMARK NOTES"
|
14
|
+
placemark.tag_list.should == "tag1, tag2"
|
15
|
+
placemark.latitude.should == 9.0
|
16
|
+
placemark.longitude.should == 10.0
|
17
|
+
placemark.favorites_count.should == 0
|
18
|
+
placemark.short_url.should == "http://www.tagcrumbs.com/p/ZmE5ZmR"
|
19
|
+
placemark.private.should be_false
|
20
|
+
|
21
|
+
placemark.created_at.should be_an_instance_of(Time)
|
22
|
+
placemark.updated_at.should be_an_instance_of(Time)
|
23
|
+
|
24
|
+
# has one associations
|
25
|
+
placemark.user.class.should == Tagcrumbs::User
|
26
|
+
placemark.user.loaded?.should be_true
|
27
|
+
placemark.user.resource_url.should == tagcrumbs_url('/sascha', format)
|
28
|
+
placemark.user.username.should == 'sascha'
|
29
|
+
|
30
|
+
placemark.address.class.should == Tagcrumbs::Address
|
31
|
+
placemark.address.loaded?.should be_true
|
32
|
+
placemark.address.resource_url.should == tagcrumbs_url('/sascha/placemarks/placemark-name/address', format)
|
33
|
+
|
34
|
+
# has many associations
|
35
|
+
placemark.recommendations.class.should == Tagcrumbs::Array
|
36
|
+
placemark.recommendations.loaded?.should be_false
|
37
|
+
placemark.recommendations.resource_url.should == tagcrumbs_url('/sascha/placemarks/placemark-name/recommendations', format)
|
38
|
+
|
39
|
+
placemark.comments.class.should == Tagcrumbs::Array
|
40
|
+
placemark.comments.loaded?.should be_false
|
41
|
+
placemark.comments.resource_url.should == tagcrumbs_url('/sascha/placemarks/placemark-name/comments', format)
|
42
|
+
|
43
|
+
placemark.links.class.should == Tagcrumbs::Array
|
44
|
+
placemark.links.loaded?.should be_false
|
45
|
+
placemark.links.resource_url.should == tagcrumbs_url('/sascha/placemarks/placemark-name/links', format)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should load suggestions" do
|
50
|
+
stub_get('/you', 'user.xml', [200])
|
51
|
+
stub_get('/sascha/tagcrumbs/suggestions.xml?latitude=10&longitude=9', 'suggestions.xml', [200])
|
52
|
+
|
53
|
+
placemark = Tagcrumbs::Placemark.new(:latitude => 10, :longitude => 9)
|
54
|
+
suggestions = placemark.suggestions
|
55
|
+
|
56
|
+
suggestions.should be_an_instance_of(Tagcrumbs::Suggestions)
|
57
|
+
suggestions.loaded?.should be_true
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
end
|