tagcrumbs 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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/lib/tagcrumbs.rb +232 -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 +327 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Tagcrumbs::Array do
|
|
4
|
+
before(:each) do
|
|
5
|
+
@array = Tagcrumbs::Array.new
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it "should reset" do
|
|
9
|
+
@array.properties = {1 => 2}
|
|
10
|
+
@array.resource_url = 'test.de'
|
|
11
|
+
@array.loaded = true
|
|
12
|
+
@array.array = [1,2,3]
|
|
13
|
+
|
|
14
|
+
@array.reset!
|
|
15
|
+
|
|
16
|
+
@array.properties.should == {}
|
|
17
|
+
@array.resource_url.should be_nil
|
|
18
|
+
@array.loaded.should be_false
|
|
19
|
+
@array.array.should == []
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should set properties and typecast" do
|
|
23
|
+
@array.properties = {'xlink:href' => 'array_url', 'page' => '5', 'total_entries' => '20'}
|
|
24
|
+
|
|
25
|
+
@array.resource_url.should == 'array_url'
|
|
26
|
+
@array.properties[:page].should == '5'
|
|
27
|
+
@array.page.should == 5
|
|
28
|
+
@array.properties[:total_entries].should == '20'
|
|
29
|
+
@array.total_entries.should == 20
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should delegate missing methods to the array" do
|
|
33
|
+
@array.size.should == 0
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should initialize from document" do
|
|
37
|
+
@array.initialize_from_document(fixture_file('placemarks.xml'))
|
|
38
|
+
|
|
39
|
+
@array.resource_url.should == 'http://www.tagcrumbs.com/sascha/tagcrumbs.xml'
|
|
40
|
+
@array.loaded.should == true
|
|
41
|
+
@array.properties.should be_present
|
|
42
|
+
|
|
43
|
+
@array.properties[:page].should == '1'
|
|
44
|
+
@array.page.should == 1
|
|
45
|
+
@array.properties[:per_page].should == '10'
|
|
46
|
+
@array.per_page.should == 10
|
|
47
|
+
@array.properties[:pages].should == '21'
|
|
48
|
+
@array.pages.should == 21
|
|
49
|
+
@array.properties[:total_entries].should == '206'
|
|
50
|
+
@array.total_entries.should == 206
|
|
51
|
+
|
|
52
|
+
@array.properties[:sort].should == 'date'
|
|
53
|
+
@array.sort.should == 'date'
|
|
54
|
+
@array.properties[:order].should == 'desc'
|
|
55
|
+
@array.order.should == 'desc'
|
|
56
|
+
|
|
57
|
+
@array.size.should == 3
|
|
58
|
+
@array[0].should be_an_instance_of(Tagcrumbs::Placemark)
|
|
59
|
+
@array[1].should be_an_instance_of(Tagcrumbs::Placemark)
|
|
60
|
+
@array[2].should be_an_instance_of(Tagcrumbs::Placemark)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
2
|
+
|
|
3
|
+
class Tagcrumbs::AccessorTestModel < Tagcrumbs::Model
|
|
4
|
+
can_be :created, :updated
|
|
5
|
+
|
|
6
|
+
readable_attributes :readable1, :readable2
|
|
7
|
+
writeable_attributes :writeable1, :writeable2
|
|
8
|
+
|
|
9
|
+
has_one :tagcrumb
|
|
10
|
+
has_one :has_one_subitem
|
|
11
|
+
has_one :has_one_subitem_modifiable, :modifiable => true
|
|
12
|
+
|
|
13
|
+
has_many :has_many_subitems
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe Tagcrumbs::Accessors do
|
|
18
|
+
before(:each) do
|
|
19
|
+
@model = Tagcrumbs::AccessorTestModel.new(:writeable1 => 1, :writeable2 => 2, :has_one_subitem_modifiable => 'url')
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should have nodes" do
|
|
23
|
+
@model.nodes.should == {}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should have nodes_updates" do
|
|
27
|
+
@model.nodes_updates.keys.should have(2).items
|
|
28
|
+
@model.nodes_updates[:writeable1].should be_an_instance_of(Tagcrumbs::Node)
|
|
29
|
+
@model.nodes_updates[:writeable2].should be_an_instance_of(Tagcrumbs::Node)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should have has_one associations" do
|
|
33
|
+
@model.has_one_associations.should == {}
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should have has_one association updates" do
|
|
37
|
+
@model.has_one_associations_updates.should == {:has_one_subitem_modifiable => 'url'}
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should have has_one association updates" do
|
|
41
|
+
@model.has_many_associations.should == {}
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should restore changes" do
|
|
45
|
+
@model.nodes_updates.keys.should have(2).items
|
|
46
|
+
@model.has_one_associations_updates.keys.should have(1).item
|
|
47
|
+
|
|
48
|
+
@model.restore!
|
|
49
|
+
|
|
50
|
+
@model.nodes_updates.should == {}
|
|
51
|
+
@model.has_one_associations_updates.should == {}
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "should update attributes" do
|
|
55
|
+
@model.attributes = {:writeable1 => 'one'}
|
|
56
|
+
|
|
57
|
+
@model.nodes_updates[:writeable1].value.should == 'one'
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "should return all attributes" do
|
|
61
|
+
@model.attributes.should == {:writeable1 => 1, :writeable2 => 2, :has_one_subitem_modifiable => 'url', :readable1 => nil, :readable2 => nil}
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "should return modifiable-only attributes" do
|
|
65
|
+
@model.attributes(:modifiable_only => true).should == {:writeable1 => 1, :writeable2 => 2, :has_one_subitem_modifiable => 'url'}
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "should inspect" do
|
|
69
|
+
@model.inspect.should_not be_blank
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "should return the class name without modules" do
|
|
73
|
+
@model.class_name.should == 'AccessorTestModel'
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "should have a create url" do
|
|
77
|
+
stub_get('/you', 'user.xml', [200])
|
|
78
|
+
|
|
79
|
+
lambda {
|
|
80
|
+
@model.create_url
|
|
81
|
+
}.should raise_error(Tagcrumbs::CreateURLMissing)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
it "should have an error on create url if object can not be created" do
|
|
86
|
+
@model.stub!(:can_be?).and_return(false)
|
|
87
|
+
|
|
88
|
+
lambda {
|
|
89
|
+
@model.create_url
|
|
90
|
+
}.should raise_error(Tagcrumbs::CreateImpossible)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it "should create a has_many_url method" do
|
|
94
|
+
stub_get('/you', 'user.xml', [200])
|
|
95
|
+
|
|
96
|
+
Tagcrumbs.current_user.tagcrumbs_url.should == tagcrumbs_url('/sascha/tagcrumbs.xml')
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it "should find out what actions can be done" do
|
|
100
|
+
@model.can_be?(:created).should be_true
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it "should alias tagcrumb to placemark" do
|
|
104
|
+
@model.placemark = 123
|
|
105
|
+
@model.tagcrumb.should == 123
|
|
106
|
+
@model.placemark.should == 123
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
describe "(Class Methods)" do
|
|
110
|
+
it "should have can_be options" do
|
|
111
|
+
Tagcrumbs::AccessorTestModel.can_be_options.should == [:created, :updated]
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it "should have all attributes" do
|
|
115
|
+
Tagcrumbs::AccessorTestModel.attributes.sort{|a, b| a.to_s <=> b.to_s}.should == [:writeable2, :writeable1, :readable1, :readable2, :has_one_subitem_modifiable].sort{|a, b| a.to_s <=> b.to_s}
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it "should have modifiable_only attributes" do
|
|
119
|
+
Tagcrumbs::AccessorTestModel.attributes(:modifiable_only => true).sort{|a, b| a.to_s <=> b.to_s}.should == [:writeable2, :writeable1, :has_one_subitem_modifiable].sort{|a, b| a.to_s <=> b.to_s}
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Tagcrumbs::Activity do
|
|
4
|
+
it "should create from a document" do
|
|
5
|
+
Tagcrumbs.supported_formats.keys.each do |format|
|
|
6
|
+
activity = Tagcrumbs::Activity.new_from_document(fixture_file("activity", format), format)
|
|
7
|
+
|
|
8
|
+
activity.resource_url.should == tagcrumbs_url('/sascha/activities/460', format)
|
|
9
|
+
activity.new_record.should be_false
|
|
10
|
+
activity.loaded.should be_true
|
|
11
|
+
|
|
12
|
+
activity.event_type.should == 'create'
|
|
13
|
+
activity.created_at.should be_an_instance_of(Time)
|
|
14
|
+
activity.updated_at.should be_an_instance_of(Time)
|
|
15
|
+
|
|
16
|
+
# has one associations
|
|
17
|
+
activity.user.class.should == Tagcrumbs::User
|
|
18
|
+
activity.user.loaded?.should be_true
|
|
19
|
+
activity.user.resource_url.should == tagcrumbs_url('/sascha', format)
|
|
20
|
+
|
|
21
|
+
activity.subject.class.should == Tagcrumbs::Comment
|
|
22
|
+
activity.subject.loaded?.should be_true
|
|
23
|
+
activity.subject.resource_url.should == tagcrumbs_url('/sascha/comments/84', format)
|
|
24
|
+
activity.subject.text.should == 'COMMENT TEXT'
|
|
25
|
+
|
|
26
|
+
activity.secondary_subject.class.should == Tagcrumbs::Placemark
|
|
27
|
+
activity.secondary_subject.loaded?.should be_true
|
|
28
|
+
activity.secondary_subject.resource_url.should == tagcrumbs_url('/sascha/placemarks/placemark-name', format)
|
|
29
|
+
activity.secondary_subject.name.should == 'PLACEMARK NAME'
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -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
|