osm 0.0.11 → 0.0.12

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.
@@ -0,0 +1,58 @@
1
+ module Osm
2
+
3
+ class RegisterData
4
+
5
+ attr_reader :member_id, :first_name, :last_name, :section_id, :grouping_id, :total, :attendance
6
+ # @!attribute [r] member_id
7
+ # @return [Fixnum] The OSM ID for the member
8
+ # @!attribute [r] grouping_id
9
+ # @return [Fixnum] The OSM ID for the member's grouping
10
+ # @!attribute [r] section_id
11
+ # @return [Fixnum] The OSM ID for the member's section
12
+ # @!attribute [r] first_name
13
+ # @return [String] The member's first name
14
+ # @!attribute [r] last_name
15
+ # @return [String] The member's last name
16
+ # @!attribute [r] total
17
+ # @return [FixNum] Tooltip for the field
18
+ # @!attribute [r] attendance
19
+ # @return [Hash] The data for each field - keys are the date, values one of 'Yes' (present), 'No' (known absence) or nil (absent)
20
+
21
+ # Initialize a new RegisterData
22
+ # @param [Hash] attributes the hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
23
+ def initialize(attributes={})
24
+ [:member_id, :grouping_id, :section_id].each do |attribute|
25
+ raise ArgumentError, ":#{attribute} must be nil or a Fixnum > 0" unless attributes[attribute].nil? || (attributes[attribute].is_a?(Fixnum) && attributes[attribute] > 0)
26
+ end
27
+ raise ArgumentError, ':total must be a Fixnum >= 0' unless (attributes[:total].is_a?(Fixnum) && attributes[:total] >= 0)
28
+ [:first_name, :last_name].each do |attribute|
29
+ raise ArgumentError, "#{attribute} must be nil or a String" unless attributes[attribute].nil? || attributes[attribute].is_a?(String)
30
+ end
31
+ raise ArgumentError, ':attendance must be a Hash' unless attributes[:attendance].is_a?(Hash)
32
+
33
+ attributes.each { |k,v| instance_variable_set("@#{k}", v) }
34
+ end
35
+
36
+
37
+ # Initialize a new RegisterData from api data
38
+ # @param [Hash] data the hash of data provided by the API
39
+ def self.from_api(data)
40
+ attributes = {}
41
+ attributes[:member_id] = Osm::to_i_or_nil(data['scoutid'])
42
+ attributes[:grouping_id] = Osm::to_i_or_nil(data['patrolid'])
43
+ attributes[:section_id] = Osm::to_i_or_nil(data['sectionid'])
44
+ attributes[:first_name] = data['firstname']
45
+ attributes[:last_name] = data['lastname']
46
+ attributes[:total] = data['total'].to_i
47
+
48
+ attributes[:attendance] = {}
49
+ data.except('scoutid', 'patrolid', 'sectionid', 'firstname', 'lastname', 'total').keys.each do |key|
50
+ attributes[:attendance][Date.strptime(key, '%Y-%m-%d')] = data[key]
51
+ end
52
+
53
+ new(attributes)
54
+ end
55
+
56
+ end
57
+
58
+ end
@@ -0,0 +1,39 @@
1
+ module Osm
2
+
3
+ class RegisterField
4
+
5
+ attr_reader :id, :name, :tooltip
6
+ # @!attribute [r] id
7
+ # @return [String] OSM identifier for the field
8
+ # @!attribute [r] name
9
+ # @return [String] Human readable name for the field
10
+ # @!attribute [r] tooltip
11
+ # @return [String] Tooltip for the field
12
+
13
+ # Initialize a new RegisterField
14
+ # @param [Hash] attributes the hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
15
+ def initialize(attributes={})
16
+ [:id, :name].each do |attribute|
17
+ raise ArgumentError, "#{attribute} must be a String" unless attributes[attribute].is_a?(String)
18
+ end
19
+ raise ArgumentError, ':tooltip must be a String' unless attributes[:tooltip].nil? || attributes[:tooltip].is_a?(String)
20
+
21
+ attributes.each { |k,v| instance_variable_set("@#{k}", v) }
22
+
23
+ @tooltip ||= ''
24
+ end
25
+
26
+
27
+ # Initialize a new RegisterField from api data
28
+ # @param [Hash] data the hash of data provided by the API
29
+ def self.from_api(data)
30
+ new({
31
+ :id => data['field'],
32
+ :name => data['name'],
33
+ :tooltip => data['tooltip'],
34
+ })
35
+ end
36
+
37
+ end
38
+
39
+ end
data/lib/osm/role.rb CHANGED
@@ -12,18 +12,35 @@ module Osm
12
12
  # @!attribute [r] permissions
13
13
  # @return [Hash] the permissions the user has in this role
14
14
 
15
- # Initialize a new UserRole using the hash returned by the API call
16
- # @param data the hash of data for the object returned by the API
17
- def initialize(data)
18
- @section = Osm::Section.new(data['sectionid'], data['sectionname'], ActiveSupport::JSON.decode(data['sectionConfig']), self)
19
- @group_name = data['groupname']
20
- @group_id = Osm::to_i_or_nil(data['groupid'])
21
- @permissions = data['permissions'].is_a?(Hash) ? Osm::symbolize_hash(data['permissions']) : {}
15
+ # Initialize a new ApiAccess
16
+ # @param [Hash] attributes the hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
17
+ def initialize(attributes={})
18
+ raise ArgumentError, ':group_id must be nil or a Fixnum > 0' unless attributes[:group_id].nil? || (attributes[:group_id].is_a?(Fixnum) && attributes[:group_id] > 0)
19
+ raise ArgumentError, ':group_name must be nil or a String' unless attributes[:group_name].nil? || attributes[:group_name].is_a?(String)
20
+ raise ArgumentError, ':permissions must be nil or a Hash' unless attributes[:permissions].nil? || attributes[:permissions].is_a?(Hash)
21
+
22
+ attributes.each { |k,v| instance_variable_set("@#{k}", v) }
23
+
24
+ @name ||= ''
25
+ @permissions ||= {}
26
+ end
27
+
28
+
29
+ # Initialize a new ApiAccess from api data
30
+ # @param [Hash] data the hash of data provided by the API
31
+ def self.from_api(data)
32
+ attributes = {}
33
+ attributes[:section] = Osm::Section.from_api(data['sectionid'], data['sectionname'], ActiveSupport::JSON.decode(data['sectionConfig']), self)
34
+ attributes[:group_name] = data['groupname']
35
+ attributes[:group_id] = Osm::to_i_or_nil(data['groupid'])
22
36
 
23
37
  # Convert permission values to a number
24
- @permissions.each_key do |key|
25
- @permissions[key] = @permissions[key].to_i
38
+ permissions = data['permissions'].is_a?(Hash) ? Osm::symbolize_hash(data['permissions']) : {}
39
+ permissions.each_key do |key|
40
+ permissions[key] = permissions[key].to_i
26
41
  end
42
+
43
+ new(attributes.merge(:permissions => permissions))
27
44
  end
28
45
 
29
46
  # Determine if this role has read access for the provided permission
data/lib/osm/section.rb CHANGED
@@ -2,7 +2,7 @@ module Osm
2
2
 
3
3
  class Section
4
4
 
5
- attr_reader :id, :name, :subscription_level, :subscription_expires, :type, :num_scouts, :column_names, :fields, :intouch_fields, :mobile_fields, :extra_records, :role
5
+ attr_reader :id, :name, :subscription_level, :subscription_expires, :type, :num_scouts, :column_names, :fields, :intouch_fields, :mobile_fields, :flexi_records, :role
6
6
  # @!attribute [r] id
7
7
  # @return [Fixnum] the id for the section
8
8
  # @!attribute [r] name
@@ -23,44 +23,71 @@ module Osm
23
23
  # @return [Hash] which columns are shown in OSM's in touch reports
24
24
  # @!attribute [r] mobile_fields
25
25
  # @return [Hash] which columns are shown in the OSM mobile app
26
- # @!attribute [r] extraRecords
27
- # @return [Array<hash>] list of the extra records the section has
26
+ # @!attribute [r] flexi_records
27
+ # @return [Array<FlexiRecord>] list of the extra records the section has
28
28
  # @!attribute [r] role
29
29
  # @return [Osm::Role] the role linking the user to this section
30
30
 
31
31
 
32
- # Initialize a new SectionConfig using the hash returned by the API call
33
- # @param id the section ID used by the API to refer to this section
34
- # @param name the name given to the sction in OSM
35
- # @param data the hash of data for the object returned by the API
36
- # @param role the Osm::Role linked with this section
37
- def initialize(id, name, data, role)
32
+ # Initialize a new Section
33
+ # @param [Hash] attributes the hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
34
+ def initialize(attributes={})
35
+ raise ArgumentError, ':id must be nil or a Fixnum > 0' unless attributes[:id].nil? || (attributes[:id].is_a?(Fixnum) && attributes[:id] > 0)
36
+ raise ArgumentError, ':section_name must be nil or a String' unless attributes[:section_name].nil? || attributes[:section_name].is_a?(String)
37
+ raise ArgumentError, ':num_scouts must be nil or a Fixnum >= 0' unless attributes[:num_scouts].nil? || (attributes[:num_scouts].is_a?(Fixnum) && attributes[:num_scouts] > 0)
38
+ [:column_names, :fields, :intouch_fields, :mobile_fields].each do |attribute|
39
+ raise ArgumentError, ":#{attribute} must be nil or a Hash" unless attributes[attribute].nil? || attributes[attribute].is_a?(Hash)
40
+ end
41
+ [:type, :subscription_level].each do |attribute|
42
+ raise ArgumentError, ":#{attribute} must be nil or a Symbol" unless attributes[attribute].nil? || attributes[attribute].is_a?(Symbol)
43
+ end
44
+ raise ArgumentError, ':flexi_records must be nil or an Array' unless attributes[:flexi_records].nil? || attributes[:flexi_records].is_a?(Array)
45
+
46
+ attributes.each { |k,v| instance_variable_set("@#{k}", v) }
47
+
48
+ @section_name ||= ''
49
+ @column_names ||= {}
50
+ @fields ||= {}
51
+ @intouch_fields ||= {}
52
+ @mobile_fields ||= {}
53
+ @flexi_records ||= []
54
+ @subscription_level ||= :unknown
55
+ @type ||= :unknown
56
+ end
57
+
58
+
59
+ # Initialize a new Sections from api data
60
+ # @param [Fixnum] id the section ID used by the API to refer to this section
61
+ # @param [String] name the name given to the sction in OSM
62
+ # @param [Hash] data the hash of data for the object returned by the API
63
+ # @param {Osm::Role] role the Osm::Role linked with this section
64
+ def self.from_api(id, name, data, role)
38
65
  subscription_levels = [:bronze, :silver, :gold]
39
66
  subscription_level = data['subscription_level'].to_i - 1
40
67
 
41
- @id = Osm::to_i_or_nil(id)
42
- @name = name
43
- @subscription_level = (subscription_levels[subscription_level] unless subscription_level < 0) || :unknown
44
- @subscription_expires = data['subscription_expires'] ? Date.parse(data['subscription_expires'], 'yyyy-mm-dd') : nil
45
- @type = !data['sectionType'].nil? ? data['sectionType'].to_sym : :unknown
46
- @num_scouts = data['numscouts']
47
- @column_names = data['columnNames'].is_a?(Hash) ? Osm::symbolize_hash(data['columnNames']) : {}
48
- @fields = data['fields'].is_a?(Hash) ? Osm::symbolize_hash(data['fields']) : {}
49
- @intouch_fields = data['intouch'].is_a?(Hash) ? Osm::symbolize_hash(data['intouch']) : {}
50
- @mobile_fields = data['mobFields'].is_a?(Hash) ? Osm::symbolize_hash(data['mobFields']) : {}
51
- @extra_records = data['extraRecords'].is_a?(Array) ? data['extraRecords'] : []
52
- @role = role
53
-
54
- # Symbolise the keys in each hash of the extra_records array
55
- @extra_records.each do |item|
56
- # Expect item to be: {:name=>String, :extraid=>Fixnum}
57
- # Sometimes get item as: [String, {"name"=>String, "extraid"=>Fixnum}]
58
- if item.is_a?(Array)
59
- item = Osm::symbolize_hash(item[1])
60
- else
61
- item = Osm::symbolize_hash(item)
62
- end
68
+ attributes = {
69
+ :id => Osm::to_i_or_nil(id),
70
+ :name => name,
71
+ :subscription_level => (subscription_levels[subscription_level] unless subscription_level < 0) || :unknown,
72
+ :subscription_expires => data['subscription_expires'] ? Date.parse(data['subscription_expires'], 'yyyy-mm-dd') : nil,
73
+ :type => !data['sectionType'].nil? ? data['sectionType'].to_sym : :unknown,
74
+ :num_scouts => data['numscouts'],
75
+ :column_names => data['columnNames'].is_a?(Hash) ? Osm::symbolize_hash(data['columnNames']) : {},
76
+ :fields => data['fields'].is_a?(Hash) ? Osm::symbolize_hash(data['fields']) : {},
77
+ :intouch_fields => data['intouch'].is_a?(Hash) ? Osm::symbolize_hash(data['intouch']) : {},
78
+ :mobile_fields => data['mobFields'].is_a?(Hash) ? Osm::symbolize_hash(data['mobFields']) : {},
79
+ :role => role,
80
+ :flexi_records => [],
81
+ }
82
+
83
+
84
+ # Populate arrays
85
+ (data['extraRecords'].is_a?(Array) ? data['extraRecords'] : []).each do |record_data|
86
+ attributes[:flexi_records].push FlexiRecord.from_api(record_data)
63
87
  end
88
+ attributes[:flexi_records].freeze
89
+
90
+ new(attributes)
64
91
  end
65
92
 
66
93
  # Check if this section is one of the youth sections
@@ -102,6 +129,41 @@ module Osm
102
129
  self.id == another_section.try(:id)
103
130
  end
104
131
 
105
- end
106
132
 
107
- end
133
+
134
+ private
135
+ class FlexiRecord
136
+
137
+ attr_reader :id, :name
138
+ # @!attribute [r] id
139
+ # @return [Fixnum] the aid of the flexi-record
140
+ # @!attribute [r] name
141
+ # @return [String] the name given to the flexi-record
142
+
143
+ # Initialize a new ApiAccess
144
+ # @param [Hash] attributes the hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
145
+ def initialize(attributes={})
146
+ raise ArgumentError, ':id must be a Fixnum > 0' unless (attributes[:id].is_a?(Fixnum) && attributes[:id] > 0)
147
+ raise ArgumentError, ':name must be a String' unless attributes[:name].is_a?(String)
148
+
149
+ attributes.each { |k,v| instance_variable_set("@#{k}", v) }
150
+ end
151
+
152
+
153
+ # Initialize a new ApiAccess from api data
154
+ # @param [Hash] data the hash of data provided by the API
155
+ def self.from_api(data)
156
+ # Expect item to be: {:name=>String, :extraid=>Fixnum}
157
+ # Sometimes get item as: [String, {"name"=>String, "extraid"=>Fixnum}]
158
+ data = data[1] if data.is_a?(Array)
159
+
160
+ new({
161
+ :id => Osm::to_i_or_nil(data['extraid']),
162
+ :name => data['name'],
163
+ })
164
+ end
165
+ end # FlexiRecord
166
+
167
+ end # Section
168
+
169
+ end # Module
data/lib/osm/term.rb CHANGED
@@ -14,14 +14,29 @@ module Osm
14
14
  # @!attribute [r] end
15
15
  # @return [Date] when the term ends
16
16
 
17
- # Initialize a new Term using the hash returned by the API call
18
- # @param data the hash of data for the object returned by the API
19
- def initialize(data)
20
- @id = Osm::to_i_or_nil(data['termid'])
21
- @section_id = Osm::to_i_or_nil(data['sectionid'])
22
- @name = data['name']
23
- @start = Osm::parse_date(data['startdate'])
24
- @end = Osm::parse_date(data['enddate'])
17
+ # Initialize a new Term
18
+ # @param [Hash] attributes the hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
19
+ def initialize(attributes={})
20
+ raise ArgumentError, ':id must be nil or a Fixnum > 0' unless attributes[:id].nil? || (attributes[:id].is_a?(Fixnum) && attributes[:id] > 0)
21
+ raise ArgumentError, ':section_id must be nil or a Fixnum > 0' unless attributes[:section_id].nil? || (attributes[:section_id].is_a?(Fixnum) && attributes[:section_id] > 0)
22
+ raise ArgumentError, ':name must be nil or a String' unless attributes[:name].nil? || attributes[:name].is_a?(String)
23
+ raise ArgumentError, ':start must be nil or a Date' unless attributes[:start].nil? || attributes[:start].is_a?(Date)
24
+ raise ArgumentError, ':end must be nil or a Date' unless attributes[:end].nil? || attributes[:end].is_a?(Date)
25
+
26
+ attributes.each { |k,v| instance_variable_set("@#{k}", v) }
27
+ end
28
+
29
+
30
+ # Initialize a new Term from api data
31
+ # @param [Hash] data the hash of data provided by the API
32
+ def self.from_api(data)
33
+ new(
34
+ :id => Osm::to_i_or_nil(data['termid']),
35
+ :section_id => Osm::to_i_or_nil(data['sectionid']),
36
+ :name => data['name'],
37
+ :start => Osm::parse_date(data['startdate']),
38
+ :end => Osm::parse_date(data['enddate']),
39
+ )
25
40
  end
26
41
 
27
42
  # Determine if the term is completly before the passed date
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
 
4
4
  describe "Activity" do
5
5
 
6
- it "Create" do
6
+ it "Create from API data" do
7
7
  data = {
8
8
  'details' => {
9
9
  'activityid' => '1',
@@ -34,10 +34,26 @@ describe "Activity" do
34
34
  ],
35
35
  'sections' => ['beavers', 'cubs'],
36
36
  'tags' => ['Tag 1', 'Tag2'],
37
- 'files' => [],
38
- 'badges' => []
37
+ 'files' => [
38
+ {
39
+ 'fileid' => '6',
40
+ 'activityid' => '1',
41
+ 'filename' => 'File Name',
42
+ 'name' => 'Name',
43
+ }
44
+ ],
45
+ 'badges' => [
46
+ {
47
+ 'activityid' => '1',
48
+ 'section' => 'section',
49
+ 'badgetype' => 'type',
50
+ 'badge' => 'badge',
51
+ 'columnname' => 'col_name',
52
+ 'label' => 'This is a label',
53
+ }
54
+ ]
39
55
  }
40
- activity = Osm::Activity.new(data)
56
+ activity = Osm::Activity.from_api(data)
41
57
 
42
58
  activity.id.should == 1
43
59
  activity.version.should == 0
@@ -54,11 +70,22 @@ describe "Activity" do
54
70
  activity.editable.should == true
55
71
  activity.deletable.should == false
56
72
  activity.used.should == 3
57
- activity.versions.should == [{:value => 0, :user_id => 1, :firstname => 'Alice', :label => 'Current version - Alice', :selected => true}]
73
+ activity.versions[0].version.should == 0
74
+ activity.versions[0].created_by.should == 1
75
+ activity.versions[0].created_by_name.should == 'Alice'
76
+ activity.versions[0].label.should == 'Current version - Alice'
58
77
  activity.sections.should == [:beavers, :cubs]
59
78
  activity.tags.should == ['Tag 1', 'Tag2']
60
- activity.files.should == []
61
- activity.badges.should == []
79
+ activity.files[0].id.should == 6
80
+ activity.files[0].activity_id.should == 1
81
+ activity.files[0].file_name.should == 'File Name'
82
+ activity.files[0].name.should == 'Name'
83
+ activity.badges[0].activity_id.should == 1
84
+ activity.badges[0].section_type.should == :section
85
+ activity.badges[0].type.should == :type
86
+ activity.badges[0].badge.should == 'badge'
87
+ activity.badges[0].requirement.should == 'col_name'
88
+ activity.badges[0].label.should == 'This is a label'
62
89
  end
63
90
 
64
91
  end
@@ -4,13 +4,13 @@ require 'spec_helper'
4
4
 
5
5
  describe "API Access" do
6
6
 
7
- it "Create" do
7
+ it "Create from API data" do
8
8
  data = {
9
9
  'apiid' => '1',
10
10
  'name' => 'Name',
11
11
  'permissions' => {'permission' => '100'},
12
12
  }
13
- api_access = Osm::ApiAccess.new(data)
13
+ api_access = Osm::ApiAccess.from_api(data)
14
14
 
15
15
  api_access.id.should == 1
16
16
  api_access.name.should == 'Name'
@@ -20,11 +20,11 @@ describe "API Access" do
20
20
 
21
21
  it "Allows interegation of the permissions hash" do
22
22
  api_access = Osm::ApiAccess.new({
23
- 'apiid' => '1',
24
- 'name' => 'Name',
25
- 'permissions' => {
26
- 'read_only' => 10,
27
- 'read_write' => 20,
23
+ :id => 1,
24
+ :name => 'Name',
25
+ :permissions => {
26
+ :read_only => 10,
27
+ :read_write => 20,
28
28
  },
29
29
  })
30
30
 
@@ -43,8 +43,8 @@ describe "API Access" do
43
43
  Osm::Api.stub(:api_id) { '1' }
44
44
 
45
45
  apis = {
46
- :ours => Osm::ApiAccess.new({'apiid' => '1', 'name' => 'Name', 'permissions' => {}}),
47
- :not_ours => Osm::ApiAccess.new({'apiid' => '2', 'name' => 'Name', 'permissions' => {}}),
46
+ :ours => Osm::ApiAccess.new({:id => 1, :name => 'Name', :permissions => {}}),
47
+ :not_ours => Osm::ApiAccess.new({:id => 2, :name => 'Name', :permissions => {}}),
48
48
  }
49
49
 
50
50
  apis[:ours].our_api?.should == true
data/spec/osm/api_spec.rb CHANGED
@@ -25,7 +25,7 @@ end
25
25
 
26
26
  describe "API" do
27
27
 
28
- before(:each) do
28
+ before :each do
29
29
  @api_config = {
30
30
  :api_id => '1',
31
31
  :api_token => 'API TOKEN',
@@ -112,7 +112,7 @@ describe "API" do
112
112
  it "Fetch the notepad for a section" do
113
113
  FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getNotepads", :body => {"1" => "Section 1", "2" => "Section 2"}.to_json)
114
114
  Osm::Api.new('1', '2').get_notepad(1).should == 'Section 1'
115
- Osm::Api.new('1', '2').get_notepad(Osm::Section.new(2, '', {}, nil)).should == 'Section 2'
115
+ Osm::Api.new('1', '2').get_notepad(Osm::Section.new(:id => 2)).should == 'Section 2'
116
116
  end
117
117
 
118
118
  it "Fetch the notepad for a section (invalid section/id)" do
@@ -121,7 +121,6 @@ describe "API" do
121
121
  expect{ Osm::Api.new('1', '2').get_notepad(-10) }.to raise_error(ArgumentError, 'Invalid section ID')
122
122
  expect{ Osm::Api.new('1', '2').get_notepad(0) }.to raise_error(ArgumentError, 'Invalid section ID')
123
123
 
124
- expect{ Osm::Api.new('1', '2').get_notepad(Osm::Section.new(-10, '', {}, nil)) }.to raise_error(ArgumentError, 'Invalid section ID')
125
124
  expect{ Osm::Api.new('1', '2').get_notepad('1') }.to raise_error(ArgumentError, 'Invalid type for section')
126
125
  end
127
126
 
@@ -370,7 +369,7 @@ describe "API" do
370
369
  }
371
370
  FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/users.php?action=register&sectionid=1&termid=2", :body => data.to_json)
372
371
 
373
- register = Osm::Api.new('1', '2').get_register(1, 2)
372
+ register = Osm::Api.new('1', '2').get_register_data(1, 2)
374
373
  register.is_a?(Array).should be_true
375
374
  end
376
375
 
@@ -420,7 +419,7 @@ describe "API" do
420
419
  'token' => @api_config[:api_token],
421
420
  'userid' => 'user',
422
421
  'secret' => 'secret',
423
- 'eveningid' => nil, 'sectionid' => nil, 'meetingdate' => nil, 'starttime' => nil,
422
+ 'eveningid' => nil, 'sectionid' => nil, 'meetingdate' => '2000-01-02', 'starttime' => nil,
424
423
  'endtime' => nil, 'title' => 'Unnamed meeting', 'notesforparents' =>'', 'prenotes' => '',
425
424
  'postnotes' => '', 'games' => '', 'leaders' => '', 'activity' => '[]',
426
425
  }
@@ -428,7 +427,7 @@ describe "API" do
428
427
  api.stub(:get_terms) { [] }
429
428
  HTTParty.should_receive(:post).with(url, {:body => post_data}) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"result":0}'}) }
430
429
 
431
- evening = Osm::Evening.new({}, [])
430
+ evening = Osm::Evening.new({:meeting_date => Date.new(2000, 01, 02)})
432
431
  api.update_evening(evening).should be_true
433
432
  end
434
433
 
@@ -439,7 +438,7 @@ describe "API" do
439
438
  'token' => @api_config[:api_token],
440
439
  'userid' => 'user',
441
440
  'secret' => 'secret',
442
- 'eveningid' => nil, 'sectionid' => nil, 'meetingdate' => nil, 'starttime' => nil,
441
+ 'eveningid' => nil, 'sectionid' => nil, 'meetingdate' => '2000-01-02', 'starttime' => nil,
443
442
  'endtime' => nil, 'title' => 'Unnamed meeting', 'notesforparents' =>'', 'prenotes' => '',
444
443
  'postnotes' => '', 'games' => '', 'leaders' => '', 'activity' => '[]',
445
444
  }
@@ -447,7 +446,7 @@ describe "API" do
447
446
  api.stub(:get_terms) { [] }
448
447
  HTTParty.should_receive(:post).with(url, {:body => post_data}) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"result":1}'}) }
449
448
 
450
- evening = Osm::Evening.new({}, [])
449
+ evening = Osm::Evening.new({:meeting_date => Date.new(2000, 01, 02)})
451
450
  api.update_evening(evening).should be_false
452
451
  end
453
452
  end