osm 0.1.17 → 0.2.0
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/CHANGELOG.md +45 -0
- data/Guardfile +9 -0
- data/README.md +15 -13
- data/lib/osm.rb +14 -0
- data/lib/osm/activity.rb +44 -13
- data/lib/osm/api.rb +48 -12
- data/lib/osm/api_access.rb +9 -6
- data/lib/osm/due_badges.rb +5 -4
- data/lib/osm/event.rb +87 -107
- data/lib/osm/flexi_record.rb +159 -118
- data/lib/osm/grouping.rb +41 -2
- data/lib/osm/{evening.rb → meeting.rb} +71 -64
- data/lib/osm/member.rb +88 -68
- data/lib/osm/model.rb +120 -30
- data/lib/osm/register.rb +23 -14
- data/lib/osm/section.rb +40 -100
- data/lib/osm/term.rb +35 -24
- data/osm.gemspec +2 -0
- data/spec/osm/activity_spec.rb +190 -173
- data/spec/osm/api_access_spec.rb +15 -7
- data/spec/osm/api_spec.rb +54 -27
- data/spec/osm/event_spec.rb +95 -84
- data/spec/osm/flexi_record_spec.rb +138 -35
- data/spec/osm/grouping_spec.rb +59 -1
- data/spec/osm/{evening_spec.rb → meeting_spec.rb} +53 -53
- data/spec/osm/member_spec.rb +151 -45
- data/spec/osm/model_spec.rb +28 -34
- data/spec/osm/register_spec.rb +1 -1
- data/spec/osm/section_spec.rb +49 -82
- data/spec/osm/term_spec.rb +23 -15
- data/spec/spec_helper.rb +25 -0
- data/version.rb +1 -1
- metadata +41 -18
data/lib/osm/term.rb
CHANGED
@@ -36,12 +36,14 @@ module Osm
|
|
36
36
|
cache_key = ['terms', api.user_id]
|
37
37
|
|
38
38
|
if !options[:no_cache] && cache_exist?(api, cache_key)
|
39
|
-
|
39
|
+
ids = cache_read(api, cache_key)
|
40
|
+
return get_from_ids(api, ids, 'term', options, :get_all)
|
40
41
|
end
|
41
42
|
|
42
43
|
data = api.perform_query('api.php?action=getTerms')
|
43
44
|
|
44
|
-
|
45
|
+
terms = Array.new
|
46
|
+
ids = Array.new
|
45
47
|
data.each_key do |key|
|
46
48
|
data[key].each do |term_data|
|
47
49
|
term = Osm::Term.new(
|
@@ -51,37 +53,39 @@ module Osm
|
|
51
53
|
:start => Osm::parse_date(term_data['startdate']),
|
52
54
|
:finish => Osm::parse_date(term_data['enddate']),
|
53
55
|
)
|
54
|
-
|
56
|
+
terms.push term
|
57
|
+
ids.push term.id
|
55
58
|
cache_write(api, ['term', term.id], term)
|
56
59
|
end
|
57
60
|
end
|
58
61
|
|
59
|
-
cache_write(api, cache_key,
|
60
|
-
return
|
62
|
+
cache_write(api, cache_key, ids)
|
63
|
+
return terms
|
61
64
|
end
|
62
65
|
|
63
66
|
# Get the terms that the OSM user can access for a given section
|
64
67
|
# @param [Osm::Api] api The api to use to make the request
|
65
|
-
# @param [Fixnum] section
|
68
|
+
# @param [Fixnum] section The section (or its ID) of the section to get terms for
|
66
69
|
# @!macro options_get
|
67
70
|
# @return [Array<Osm::Term>, nil] An array of terms or nil if the user can not access that section
|
68
71
|
def self.get_for_section(api, section, options={})
|
72
|
+
require_access_to_section(api, section, options)
|
69
73
|
section_id = section.to_i
|
70
|
-
return nil unless get_user_permissions(api).keys.include?(section_id)
|
71
74
|
return get_all(api, options).select{ |term| term.section_id == section_id }
|
72
75
|
end
|
73
76
|
|
74
77
|
# Get a term
|
75
|
-
# @param [Osm::Api] The api to use to make the request
|
76
|
-
# @param [Fixnum] term_id
|
78
|
+
# @param [Osm::Api] api The api to use to make the request
|
79
|
+
# @param [Fixnum] term_id The id of the required term
|
77
80
|
# @!macro options_get
|
78
81
|
# @return nil if an error occured or the user does not have access to that term
|
79
|
-
# @return [Osm::
|
82
|
+
# @return [Osm::Term]
|
80
83
|
def self.get(api, term_id, options={})
|
81
84
|
cache_key = ['term', term_id]
|
82
85
|
|
83
86
|
if !options[:no_cache] && cache_exist?(api, cache_key)
|
84
|
-
|
87
|
+
term = cache_read(api, cache_key)
|
88
|
+
return term if can_access_section?(api, term.section_id, options)
|
85
89
|
end
|
86
90
|
|
87
91
|
terms = get_all(api, options)
|
@@ -89,7 +93,7 @@ module Osm
|
|
89
93
|
|
90
94
|
terms.each do |term|
|
91
95
|
if term.id == term_id
|
92
|
-
return (
|
96
|
+
return (can_access_section?(api, term.section_id, options) ? term : nil)
|
93
97
|
end
|
94
98
|
end
|
95
99
|
return nil
|
@@ -97,9 +101,10 @@ module Osm
|
|
97
101
|
|
98
102
|
# Get the current term for a given section
|
99
103
|
# @param [Osm::Api] api The api to use to make the request
|
100
|
-
# @param [Osm::Section, Fixnum] section The section (or its ID) to get terms for
|
101
|
-
# @!macro options_get
|
104
|
+
# @param [Osm::Section, Fixnum, #to_i] section The section (or its ID) to get terms for
|
105
|
+
# @!macro options_get
|
102
106
|
# @return [Osm::Term, nil] The current term or nil if the user can not access that section
|
107
|
+
# @raise [Osm::Error] If the term doesn't have a Term which is current
|
103
108
|
def self.get_current_term_for_section(api, section, options={})
|
104
109
|
section_id = section.to_i
|
105
110
|
terms = get_for_section(api, section_id, options)
|
@@ -109,7 +114,7 @@ module Osm
|
|
109
114
|
return term if term.current?
|
110
115
|
end
|
111
116
|
|
112
|
-
raise Error, 'There is no current term for the section.'
|
117
|
+
raise Osm::Error, 'There is no current term for the section.'
|
113
118
|
end
|
114
119
|
|
115
120
|
# Create a term in OSM
|
@@ -125,6 +130,7 @@ module Osm
|
|
125
130
|
raise ArgumentError, ":name can't be nil" if options[:name].nil?
|
126
131
|
raise ArgumentError, ":start can't be nil" if options[:start].nil?
|
127
132
|
raise ArgumentError, ":finish can't be nil" if options[:finish].nil?
|
133
|
+
require_access_to_section(api, options[:section])
|
128
134
|
|
129
135
|
api_data = {
|
130
136
|
'term' => options[:name],
|
@@ -146,10 +152,12 @@ module Osm
|
|
146
152
|
|
147
153
|
|
148
154
|
# Update a term in OSM
|
149
|
-
# @param [Osm::Api] The api to use to make the request
|
155
|
+
# @param [Osm::Api] api The api to use to make the request
|
150
156
|
# @return [Boolean] if the operation suceeded or not
|
157
|
+
# @raise [Osm::ObjectIsInvalid] If the Term is invalid
|
151
158
|
def update(api)
|
152
|
-
raise ObjectIsInvalid, 'term is invalid' unless valid?
|
159
|
+
raise Osm::ObjectIsInvalid, 'term is invalid' unless valid?
|
160
|
+
require_access_to_section(api, section_id)
|
153
161
|
|
154
162
|
data = api.perform_query("users.php?action=addTerm§ionid=#{section_id}", {
|
155
163
|
'term' => name,
|
@@ -158,18 +166,21 @@ module Osm
|
|
158
166
|
'termid' => id
|
159
167
|
})
|
160
168
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
169
|
+
if data.is_a?(Hash) && data['terms'].is_a?(Hash)
|
170
|
+
reset_changed_attributes
|
171
|
+
# The cached term will be out of date - remove it
|
172
|
+
cache_delete(api, ['term', id])
|
173
|
+
return true
|
174
|
+
else
|
175
|
+
return false
|
176
|
+
end
|
166
177
|
end
|
167
178
|
|
168
179
|
|
169
180
|
|
170
181
|
# @!method initialize
|
171
182
|
# Initialize a new Term
|
172
|
-
# @param [Hash] attributes
|
183
|
+
# @param [Hash] attributes The hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
|
173
184
|
|
174
185
|
|
175
186
|
# Determine if the term is completly before the passed date
|
@@ -205,7 +216,7 @@ module Osm
|
|
205
216
|
end
|
206
217
|
|
207
218
|
# Determine if the provided date is within the term
|
208
|
-
# @param [Date] date
|
219
|
+
# @param [Date] date The date to test
|
209
220
|
# @return [Boolean] if the term started before the date and finishes after the date
|
210
221
|
def contains_date?(date)
|
211
222
|
return (start <= date) && (finish >= date)
|
data/osm.gemspec
CHANGED
@@ -26,5 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.add_development_dependency 'rake', '~> 10.0'
|
27
27
|
s.add_development_dependency 'rspec', '~> 2.11'
|
28
28
|
s.add_development_dependency 'fakeweb', '~> 1.3'
|
29
|
+
s.add_development_dependency 'guard-rspec', '~> 2.4'
|
30
|
+
s.add_development_dependency 'rb-inotify', '~> 0.8.8'
|
29
31
|
|
30
32
|
end
|
data/spec/osm/activity_spec.rb
CHANGED
@@ -1,179 +1,196 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe "
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
'used' => 3,
|
26
|
-
'versions' => [
|
27
|
-
{
|
28
|
-
'value' => '0',
|
29
|
-
'userid' => '1',
|
30
|
-
'firstname' => 'Alice',
|
31
|
-
'label' => 'Current version - Alice',
|
32
|
-
'selected' => 'selected'
|
33
|
-
}
|
34
|
-
],
|
35
|
-
'sections' => ['beavers', 'cubs'],
|
36
|
-
'tags' => ['Tag 1', 'Tag2'],
|
37
|
-
'files' => [
|
38
|
-
{
|
39
|
-
'fileid' => '6',
|
40
|
-
'activityid' => '1',
|
41
|
-
'filename' => 'File Name',
|
42
|
-
'name' => 'Name',
|
43
|
-
}
|
44
|
-
],
|
45
|
-
'badges' => [
|
46
|
-
{
|
4
|
+
describe "Activity" do
|
5
|
+
|
6
|
+
it "Get OSM link" do
|
7
|
+
activity = Osm::Activity.new(
|
8
|
+
:id => 1,
|
9
|
+
:running_time => 10,
|
10
|
+
:title => 'Title',
|
11
|
+
:description => 'Description',
|
12
|
+
:resources => 'Resources',
|
13
|
+
:instructions => 'Instructions',
|
14
|
+
:location => :indoors,
|
15
|
+
)
|
16
|
+
activity.osm_link.should == 'https://www.onlinescoutmanager.co.uk/?l=p1'
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
describe "Using The API" do
|
21
|
+
|
22
|
+
it "Get One" do
|
23
|
+
body = {
|
24
|
+
'details' => {
|
47
25
|
'activityid' => '1',
|
48
|
-
'
|
49
|
-
'
|
50
|
-
'
|
51
|
-
'
|
52
|
-
'
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
'
|
106
|
-
'
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
26
|
+
'version' => '0',
|
27
|
+
'groupid' => '2',
|
28
|
+
'userid' => '3',
|
29
|
+
'title' => 'Activity Name',
|
30
|
+
'description' => 'Description',
|
31
|
+
'resources' => 'Resources',
|
32
|
+
'instructions' => 'Instructions',
|
33
|
+
'runningtime' => '15',
|
34
|
+
'location' => 'indoors',
|
35
|
+
'shared' => '0',
|
36
|
+
'rating' => '4',
|
37
|
+
'facebook' => ''
|
38
|
+
},
|
39
|
+
'editable' => true,
|
40
|
+
'deletable' => false,
|
41
|
+
'used' => 3,
|
42
|
+
'versions' => [
|
43
|
+
{
|
44
|
+
'value' => '0',
|
45
|
+
'userid' => '1',
|
46
|
+
'firstname' => 'Alice',
|
47
|
+
'label' => 'Current version - Alice',
|
48
|
+
'selected' => 'selected'
|
49
|
+
}
|
50
|
+
],
|
51
|
+
'sections' => ['beavers', 'cubs'],
|
52
|
+
'tags' => ['Tag 1', 'Tag2'],
|
53
|
+
'files' => [
|
54
|
+
{
|
55
|
+
'fileid' => '6',
|
56
|
+
'activityid' => '1',
|
57
|
+
'filename' => 'File Name',
|
58
|
+
'name' => 'Name',
|
59
|
+
}
|
60
|
+
],
|
61
|
+
'badges' => [
|
62
|
+
{
|
63
|
+
'activityid' => '1',
|
64
|
+
'section' => 'section',
|
65
|
+
'badgetype' => 'type',
|
66
|
+
'badge' => 'badge',
|
67
|
+
'columnname' => 'col_name',
|
68
|
+
'label' => 'This is a label',
|
69
|
+
}
|
70
|
+
]
|
71
|
+
}
|
72
|
+
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/programme.php?action=getActivity&id=1", :body => body.to_json)
|
73
|
+
|
74
|
+
|
75
|
+
activity = Osm::Activity.get(@api, 1)
|
76
|
+
|
77
|
+
activity.id.should == 1
|
78
|
+
activity.version.should == 0
|
79
|
+
activity.group_id.should == 2
|
80
|
+
activity.user_id.should == 3
|
81
|
+
activity.title.should == 'Activity Name'
|
82
|
+
activity.description.should == 'Description'
|
83
|
+
activity.resources.should == 'Resources'
|
84
|
+
activity.instructions.should == 'Instructions'
|
85
|
+
activity.running_time.should == 15
|
86
|
+
activity.location.should == :indoors
|
87
|
+
activity.shared.should == 0
|
88
|
+
activity.rating.should == 4
|
89
|
+
activity.editable.should == true
|
90
|
+
activity.deletable.should == false
|
91
|
+
activity.used.should == 3
|
92
|
+
activity.versions[0].version.should == 0
|
93
|
+
activity.versions[0].created_by.should == 1
|
94
|
+
activity.versions[0].created_by_name.should == 'Alice'
|
95
|
+
activity.versions[0].label.should == 'Current version - Alice'
|
96
|
+
activity.sections.should == [:beavers, :cubs]
|
97
|
+
activity.tags.should == ['Tag 1', 'Tag2']
|
98
|
+
activity.files[0].id.should == 6
|
99
|
+
activity.files[0].activity_id.should == 1
|
100
|
+
activity.files[0].file_name.should == 'File Name'
|
101
|
+
activity.files[0].name.should == 'Name'
|
102
|
+
activity.badges[0].activity_id.should == 1
|
103
|
+
activity.badges[0].section_type.should == :section
|
104
|
+
activity.badges[0].type.should == :type
|
105
|
+
activity.badges[0].badge.should == 'badge'
|
106
|
+
activity.badges[0].requirement.should == 'col_name'
|
107
|
+
activity.badges[0].label.should == 'This is a label'
|
108
|
+
|
109
|
+
activity.valid?.should be_true
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
it "Add activity to programme (succeded)" do
|
114
|
+
url = 'https://www.onlinescoutmanager.co.uk/programme.php?action=addActivityToProgramme'
|
115
|
+
post_data = {
|
116
|
+
'apiid' => @CONFIGURATION[:api][:osm][:id],
|
117
|
+
'token' => @CONFIGURATION[:api][:osm][:token],
|
118
|
+
'userid' => 'user_id',
|
119
|
+
'secret' => 'secret',
|
120
|
+
'meetingdate' => '2000-01-02',
|
121
|
+
'sectionid' => 1,
|
122
|
+
'activityid' => 2,
|
123
|
+
'notes' => 'Notes',
|
124
|
+
}
|
125
|
+
|
126
|
+
HTTParty.should_receive(:post).with(url, {:body => post_data}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"result":0}'}) }
|
127
|
+
activity = Osm::Activity.new(:id => 2)
|
128
|
+
activity.add_to_programme(@api, 1, Date.new(2000, 1, 2), 'Notes').should be_true
|
129
|
+
end
|
130
|
+
|
131
|
+
it "Add activity to programme (failed)" do
|
132
|
+
HTTParty.should_receive(:post) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"result":1}'}) }
|
133
|
+
activity = Osm::Activity.new(:id => 2)
|
134
|
+
activity.add_to_programme(@api, 1, Date.new(2000, 1, 2), 'Notes').should be_false
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
it "Update activity in OSM (succeded)" do
|
139
|
+
url = 'https://www.onlinescoutmanager.co.uk/programme.php?action=update'
|
140
|
+
post_data = {
|
141
|
+
'apiid' => @CONFIGURATION[:api][:osm][:id],
|
142
|
+
'token' => @CONFIGURATION[:api][:osm][:token],
|
143
|
+
'userid' => 'user_id',
|
144
|
+
'secret' => 'secret',
|
145
|
+
'title' => 'title',
|
146
|
+
'description' => 'description',
|
147
|
+
'resources' => 'resources',
|
148
|
+
'instructions' => 'instructions',
|
149
|
+
'id' => 2,
|
150
|
+
'files' => '3,4',
|
151
|
+
'time' => '5',
|
152
|
+
'location' => :indoors,
|
153
|
+
'sections' => '["beavers","cubs"]',
|
154
|
+
'tags' => '["tag1","tag2"]',
|
155
|
+
'links' => '[{"activityid":"2","section":"beavers","badgetype":"t","badge":"b","columnname":"r","label":"l"}]',
|
156
|
+
'shared' => 0,
|
157
|
+
'sectionid' => 1,
|
158
|
+
'secretEdit' => true,
|
159
|
+
}
|
160
|
+
|
161
|
+
HTTParty.should_receive(:post).with(url, {:body => post_data}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"result":true}'}) }
|
162
|
+
activity = Osm::Activity.new(
|
163
|
+
:id => 2,
|
164
|
+
:title => 'title',
|
165
|
+
:description => 'description',
|
166
|
+
:resources => 'resources',
|
167
|
+
:instructions => 'instructions',
|
168
|
+
:files => [Osm::Activity::File.new(:id=>3, :activity_id=>2, :file_name=>'fn', :name=>'n'), Osm::Activity::File.new(:id=>4, :activity_id=>2, :file_name=>'fn2', :name=>'n2')],
|
169
|
+
:running_time => 5,
|
170
|
+
:location => :indoors,
|
171
|
+
:sections => [:beavers, :cubs],
|
172
|
+
:tags => ['tag1', 'tag2'],
|
173
|
+
:badges => [Osm::Activity::Badge.new(:activity_id=>2, :section_type=>:beavers, :type=>:t, :badge=>'b', :requirement=>'r', :label=>'l')],
|
174
|
+
:shared => 0,
|
175
|
+
:section_id => 1,
|
176
|
+
)
|
177
|
+
activity.update(@api, 1, true).should be_true
|
178
|
+
end
|
179
|
+
|
180
|
+
it "Update activity in OSM (failed)" do
|
181
|
+
HTTParty.should_receive(:post) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"result":false}'}) }
|
182
|
+
activity = Osm::Activity.new(
|
183
|
+
:id => 2,
|
184
|
+
:title => 'title',
|
185
|
+
:description => 'description',
|
186
|
+
:resources => 'resources',
|
187
|
+
:instructions => 'instructions',
|
188
|
+
:location => :indoors,
|
189
|
+
:running_time => 0,
|
190
|
+
)
|
191
|
+
activity.update(@api, 1, true).should be_false
|
192
|
+
end
|
193
|
+
|
113
194
|
end
|
114
195
|
|
115
|
-
|
116
|
-
HTTParty.should_receive(:post) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"result":1}'}) }
|
117
|
-
activity = Osm::Activity.new(:id => 2)
|
118
|
-
activity.add_to_programme(@api, 1, Date.new(2000, 1, 2), 'Notes').should be_false
|
119
|
-
end
|
120
|
-
|
121
|
-
|
122
|
-
it "Update activity in OSM (succeded)" do
|
123
|
-
url = 'https://www.onlinescoutmanager.co.uk/programme.php?action=update'
|
124
|
-
post_data = {
|
125
|
-
'apiid' => @CONFIGURATION[:api][:osm][:id],
|
126
|
-
'token' => @CONFIGURATION[:api][:osm][:token],
|
127
|
-
'userid' => 'user_id',
|
128
|
-
'secret' => 'secret',
|
129
|
-
'title' => 'title',
|
130
|
-
'description' => 'description',
|
131
|
-
'resources' => 'resources',
|
132
|
-
'instructions' => 'instructions',
|
133
|
-
'id' => 2,
|
134
|
-
'files' => '3,4',
|
135
|
-
'time' => '5',
|
136
|
-
'location' => :indoors,
|
137
|
-
'sections' => '["beavers","cubs"]',
|
138
|
-
'tags' => '["tag1","tag2"]',
|
139
|
-
'links' => '[{"activityid":"2","section":"beavers","badgetype":"t","badge":"b","columnname":"r","label":"l"}]',
|
140
|
-
'shared' => 0,
|
141
|
-
'sectionid' => 1,
|
142
|
-
'secretEdit' => true,
|
143
|
-
}
|
144
|
-
|
145
|
-
HTTParty.should_receive(:post).with(url, {:body => post_data}) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"result":true}'}) }
|
146
|
-
activity = Osm::Activity.new(
|
147
|
-
:id => 2,
|
148
|
-
:title => 'title',
|
149
|
-
:description => 'description',
|
150
|
-
:resources => 'resources',
|
151
|
-
:instructions => 'instructions',
|
152
|
-
:files => [Osm::Activity::File.new(:id=>3, :activity_id=>2, :file_name=>'fn', :name=>'n'), Osm::Activity::File.new(:id=>4, :activity_id=>2, :file_name=>'fn2', :name=>'n2')],
|
153
|
-
:running_time => 5,
|
154
|
-
:location => :indoors,
|
155
|
-
:sections => [:beavers, :cubs],
|
156
|
-
:tags => ['tag1', 'tag2'],
|
157
|
-
:badges => [Osm::Activity::Badge.new(:activity_id=>2, :section_type=>:beavers, :type=>:t, :badge=>'b', :requirement=>'r', :label=>'l')],
|
158
|
-
:shared => 0,
|
159
|
-
:section_id => 1,
|
160
|
-
)
|
161
|
-
activity.update(@api, 1, true).should be_true
|
162
|
-
end
|
163
|
-
|
164
|
-
it "Update activity in OSM (failed)" do
|
165
|
-
HTTParty.should_receive(:post) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"result":false}'}) }
|
166
|
-
activity = Osm::Activity.new(
|
167
|
-
:id => 2,
|
168
|
-
:title => 'title',
|
169
|
-
:description => 'description',
|
170
|
-
:resources => 'resources',
|
171
|
-
:instructions => 'instructions',
|
172
|
-
:location => :indoors,
|
173
|
-
:running_time => 0,
|
174
|
-
)
|
175
|
-
activity.update(@api, 1, true).should be_false
|
176
|
-
end
|
177
|
-
|
178
|
-
|
179
|
-
end
|
196
|
+
end
|