osm 1.2.14 → 1.2.15.dev
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +32 -0
- data/lib/osm/activity.rb +66 -35
- data/lib/osm/api.rb +7 -5
- data/lib/osm/badge.rb +371 -182
- data/lib/osm/badges.rb +28 -20
- data/lib/osm/event.rb +63 -55
- data/lib/osm/meeting.rb +56 -43
- data/lib/osm/member.rb +2 -2
- data/lib/osm/model.rb +1 -1
- data/spec/osm/activity_spec.rb +33 -17
- data/spec/osm/api_spec.rb +1 -1
- data/spec/osm/badge_spec.rb +562 -642
- data/spec/osm/badges_spec.rb +92 -51
- data/spec/osm/event_spec.rb +95 -75
- data/spec/osm/meeting_spec.rb +53 -50
- data/spec/osm/member_spec.rb +10 -0
- data/version.rb +1 -1
- metadata +4 -4
data/spec/osm/badges_spec.rb
CHANGED
@@ -8,59 +8,98 @@ describe "Badges" do
|
|
8
8
|
|
9
9
|
it "Get due badges" do
|
10
10
|
data = {
|
11
|
+
'includeStock' => true,
|
12
|
+
'count' => 2,
|
13
|
+
'badgesToBuy' => 0,
|
14
|
+
'description' => {
|
15
|
+
'93_0' => {
|
16
|
+
'badge_identifier' => '93_0',
|
17
|
+
'msg' => 'You do not have enough badges!',
|
18
|
+
'name' => 'Participation',
|
19
|
+
'picture' => '',
|
20
|
+
'typeLabel' => 'Staged',
|
21
|
+
'type_id' => 3
|
22
|
+
},
|
23
|
+
'145_0' => {
|
24
|
+
'badge_identifier' => '145_0',
|
25
|
+
'name' => 'Badge Name',
|
26
|
+
'picture' => '',
|
27
|
+
'typeLabel' => 'Activity',
|
28
|
+
'type_id' => 2
|
29
|
+
},
|
30
|
+
},
|
11
31
|
'pending' => {
|
12
|
-
'
|
32
|
+
'93_0' => [
|
13
33
|
{
|
14
|
-
'
|
34
|
+
'badge_id' => '93',
|
35
|
+
'badge_identifier' => '93_0',
|
36
|
+
'badge_version' => '0',
|
37
|
+
'completed' => '2',
|
38
|
+
'current_stock' => '20',
|
39
|
+
'extra' => 'Lvl 2',
|
15
40
|
'firstname' => 'John',
|
41
|
+
'label' => 'Staged',
|
16
42
|
'lastname' => 'Doe',
|
17
|
-
'
|
18
|
-
'
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
'
|
43
|
+
'name' => 'Participation',
|
44
|
+
'patrolid' => '1502',
|
45
|
+
'pic' => true,
|
46
|
+
'picture' => '',
|
47
|
+
'scout_id' => '1',
|
48
|
+
'sid' => '1',
|
49
|
+
'type_id' => '3',
|
50
|
+
},
|
51
|
+
{
|
52
|
+
'badge_id' => '93',
|
53
|
+
'badge_identifier' => '93_0',
|
54
|
+
'badge_version' => '0',
|
55
|
+
'completed' => '2',
|
56
|
+
'current_stock' => '20',
|
57
|
+
'extra' => 'Lvl 2',
|
23
58
|
'firstname' => 'Jane',
|
59
|
+
'label' => 'Staged',
|
24
60
|
'lastname' => 'Doe',
|
25
|
-
'
|
26
|
-
'
|
27
|
-
|
28
|
-
'
|
29
|
-
'
|
30
|
-
'
|
31
|
-
'
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
61
|
+
'name' => 'Participation',
|
62
|
+
'patrolid' => '1502',
|
63
|
+
'pic' => true,
|
64
|
+
'picture' => '',
|
65
|
+
'scout_id' => '2',
|
66
|
+
'sid' => '2',
|
67
|
+
'type_id' => '3',
|
68
|
+
},
|
69
|
+
],
|
70
|
+
'145_0' => [{
|
71
|
+
'badge_id' => '145',
|
72
|
+
'badge_identifier' => '145_0',
|
73
|
+
'badge_version' => '0',
|
74
|
+
'completed' => '1',
|
75
|
+
'current_stock' => '10',
|
76
|
+
'firstname' => 'John',
|
77
|
+
'label' => 'Activity',
|
78
|
+
'lastname' => 'Doe',
|
38
79
|
'name' => 'Badge Name',
|
39
|
-
'
|
40
|
-
'
|
41
|
-
'
|
42
|
-
|
43
|
-
|
44
|
-
'
|
45
|
-
|
46
|
-
|
47
|
-
'badge' => 'participation'
|
48
|
-
}
|
49
|
-
}
|
80
|
+
'patrolid' => '1502',
|
81
|
+
'pic' => true,
|
82
|
+
'picture' => '',
|
83
|
+
'scout_id' => '1',
|
84
|
+
'sid' => '1',
|
85
|
+
'type_id' => '2',
|
86
|
+
}],
|
87
|
+
},
|
50
88
|
}
|
51
|
-
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/
|
89
|
+
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/ext/badges/due/?action=get§ion=cubs§ionid=1&termid=2", :body => data.to_json, :content_type => 'application/json')
|
52
90
|
|
53
91
|
db = Osm::Badges.get_due_badges(@api, Osm::Section.new(:id => 1, :type => :cubs), 2)
|
54
92
|
db.empty?.should be_false
|
55
|
-
db.badge_names.should == {'
|
56
|
-
db.by_member.should == {1=>['
|
93
|
+
db.badge_names.should == {'145_0_1'=>'Activity - Badge Name', '93_0_2'=>'Staged - Participation (Lvl 2)'}
|
94
|
+
db.by_member.should == {1=>['93_0_2', '145_0_1'], 2=>['93_0_2']}
|
57
95
|
db.member_names.should == {1 => 'John Doe', 2 => 'Jane Doe'}
|
58
|
-
db.
|
96
|
+
db.badge_stock.should == {'93_0_2'=>20, '145_0_1'=>10}
|
97
|
+
db.totals.should == {'93_0_2'=>2, '145_0_1'=>1}
|
59
98
|
db.valid?.should be_true
|
60
99
|
end
|
61
100
|
|
62
101
|
it "handles an empty array representing no due badges" do
|
63
|
-
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/
|
102
|
+
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/ext/badges/due/?action=get§ion=cubs§ionid=1&termid=2", :body => '[]', :content_type => 'application/json')
|
64
103
|
db = Osm::Badges.get_due_badges(@api, Osm::Section.new(:id => 1, :type => :cubs), 2)
|
65
104
|
db.should_not be_nil
|
66
105
|
end
|
@@ -68,13 +107,13 @@ describe "Badges" do
|
|
68
107
|
|
69
108
|
it "Fetch badge stock levels" do
|
70
109
|
badges_body = {
|
71
|
-
'
|
72
|
-
|
73
|
-
'badge_1' =>
|
74
|
-
'badge_2' =>
|
75
|
-
|
110
|
+
'identifier' => 'badge_id_level',
|
111
|
+
'items' => [
|
112
|
+
{ 'shortname' => 'badge_1', 'stock' => 1, 'desired' => 0, 'due' => 0 },
|
113
|
+
{ 'shortname' => 'badge_2', 'stock' => 2, 'desired' => 0, 'due' => 0 },
|
114
|
+
]
|
76
115
|
}
|
77
|
-
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/
|
116
|
+
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/ext/badges/stock/?action=getBadgeStock§ion=beavers§ion_id=1&term_id=2", :body => badges_body.to_json, :content_type => 'application/json')
|
78
117
|
Osm::Term.stub(:get_current_term_for_section) { Osm::Term.new(:id => 2) }
|
79
118
|
|
80
119
|
section = Osm::Section.new(:id => 1, :type => :beavers)
|
@@ -84,26 +123,28 @@ describe "Badges" do
|
|
84
123
|
describe "Update badge stock levels" do
|
85
124
|
|
86
125
|
it "Succeds" do
|
87
|
-
url = "https://www.onlinescoutmanager.co.uk/
|
126
|
+
url = "https://www.onlinescoutmanager.co.uk/ext/badges.php?action=updateStock"
|
88
127
|
HTTParty.should_receive(:post).with(url, {:body => {
|
89
128
|
'apiid' => @CONFIGURATION[:api][:osm][:id],
|
90
129
|
'token' => @CONFIGURATION[:api][:osm][:token],
|
91
130
|
'userid' => 'user_id',
|
92
131
|
'secret' => 'secret',
|
93
132
|
'stock' => 10,
|
94
|
-
'
|
95
|
-
'sectionid' => 1,
|
133
|
+
'sectionid' => 2,
|
96
134
|
'section' => :beavers,
|
97
|
-
|
135
|
+
'type' => 'current',
|
136
|
+
'level' => 1,
|
137
|
+
'badge_id' => 3
|
138
|
+
}}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"ok":true}'}) }
|
98
139
|
|
99
|
-
section = Osm::Section.new(:id =>
|
100
|
-
Osm::Badges.update_stock(@api, section,
|
140
|
+
section = Osm::Section.new(:id => 2, :type => :beavers)
|
141
|
+
Osm::Badges.update_stock(@api, section, 3, 10).should be_true
|
101
142
|
end
|
102
143
|
|
103
144
|
it "Fails" do
|
104
|
-
HTTParty.stub(:post) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"
|
145
|
+
HTTParty.stub(:post) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"ok":false}'}) }
|
105
146
|
section = Osm::Section.new(:id => 1, :type => :beavers)
|
106
|
-
Osm::Badges.update_stock(@api, section,
|
147
|
+
Osm::Badges.update_stock(@api, section, 3, 10).should be_false
|
107
148
|
end
|
108
149
|
|
109
150
|
end
|
data/spec/osm/event_spec.rb
CHANGED
@@ -123,20 +123,22 @@ describe "Event" do
|
|
123
123
|
|
124
124
|
it "Create" do
|
125
125
|
bl = Osm::Event::BadgeLink.new(
|
126
|
-
:badge_key => 'artist',
|
127
126
|
:badge_type => :activity,
|
128
|
-
:requirement_key => 'a_01',
|
129
127
|
:badge_section => :cubs,
|
130
128
|
:requirement_label => 'A: Poster',
|
131
|
-
:
|
132
|
-
:
|
129
|
+
:data => 'abc',
|
130
|
+
:badge_name => 'Artist',
|
131
|
+
:badge_id => 1,
|
132
|
+
:badge_version => 0,
|
133
|
+
:requirement_id => 2,
|
133
134
|
)
|
134
135
|
|
135
|
-
bl.badge_key.should == 'artist'
|
136
136
|
bl.badge_type.should == :activity
|
137
|
-
bl.requirement_key.should == 'a_01'
|
138
137
|
bl.badge_section.should == :cubs
|
139
|
-
bl.
|
138
|
+
bl.badge_name.should == 'Artist'
|
139
|
+
bl.badge_id.should == 1
|
140
|
+
bl.badge_version.should == 0
|
141
|
+
bl.requirement_id.should == 2
|
140
142
|
bl.requirement_label.should == 'A: Poster'
|
141
143
|
bl.data.should == 'abc'
|
142
144
|
bl.valid?.should be_true
|
@@ -187,8 +189,8 @@ describe "Event" do
|
|
187
189
|
'publicnotes' => 'public notepad',
|
188
190
|
'config' => '[{"id":"f_1","name":"Name","pL":"Label","pR":"1"}]',
|
189
191
|
'badgelinks' => [
|
190
|
-
{"section"=>"cubs", "badgetype"=>"activity", "badge"=>"
|
191
|
-
{"section"=>"staged", "badgetype"=>"staged", "badge"=>"hikes", "columnname"=>"
|
192
|
+
{"section"=>"cubs", "badgetype"=>"activity", "badge"=>"activity_athletics", "columnname"=>"b", "data"=>"Yes", "badgeLongName"=>"Athletics", "columnnameLongName"=>"B: Run", "sectionLongName"=>"Cubs", "badgetypeLongName"=>"Activity", "badge_id"=>"179", "badge_version"=>"0", "column_id"=>"3"},
|
193
|
+
{"section"=>"staged", "badgetype"=>"staged", "badge"=>"hikes", "columnname"=>"custom", "data"=>"1", "badgeLongName"=>"Hikes", "columnnameLongName"=>"C: Hike name = 1", "sectionLongName"=>"Staged", "badgetypeLongName"=>"Staged", "badge_id"=>"197", "badge_version"=>"0", "column_id"=>"4"},
|
192
194
|
],
|
193
195
|
'sectionid' => '1',
|
194
196
|
'googlecalendar' => nil,
|
@@ -237,17 +239,18 @@ describe "Event" do
|
|
237
239
|
event.columns[0].name.should == 'Name'
|
238
240
|
event.columns[0].label.should == 'Label'
|
239
241
|
event.columns[0].parent_required.should be_true
|
240
|
-
event.badges[0].
|
241
|
-
event.badges[0].badge_label.should == 'Athletics'
|
242
|
+
event.badges[0].badge_name.should == 'Athletics'
|
242
243
|
event.badges[0].badge_section.should == :cubs
|
243
244
|
event.badges[0].badge_type.should == :activity
|
244
|
-
event.badges[0].
|
245
|
-
event.badges[0].data.should == ''
|
245
|
+
event.badges[0].requirement_id.should == 3
|
246
|
+
event.badges[0].data.should == 'Yes'
|
246
247
|
event.badges[0].requirement_label.should == 'B: Run'
|
247
|
-
event.badges[
|
248
|
+
event.badges[0].badge_id.should == 179
|
249
|
+
event.badges[0].badge_version.should == 0
|
250
|
+
event.badges[1].badge_name.should == 'Hikes'
|
248
251
|
event.badges[1].badge_section.should == :staged
|
249
252
|
event.badges[1].badge_type.should == :staged
|
250
|
-
event.badges[1].
|
253
|
+
event.badges[1].requirement_id.should == 4
|
251
254
|
event.badges[1].data.should == '1'
|
252
255
|
event.valid?.should be_true
|
253
256
|
end
|
@@ -604,7 +607,7 @@ describe "Event" do
|
|
604
607
|
:attendance_reminder => 1,
|
605
608
|
:allow_booking => true,
|
606
609
|
}
|
607
|
-
@badge_url = 'https://www.onlinescoutmanager.co.uk/ext/
|
610
|
+
@badge_url = 'https://www.onlinescoutmanager.co.uk/ext/badges/records/index.php?action=linkBadgeToItem§ionid=1'
|
608
611
|
end
|
609
612
|
|
610
613
|
it "'Normal badge'" do
|
@@ -613,22 +616,27 @@ describe "Event" do
|
|
613
616
|
'token' => @CONFIGURATION[:api][:osm][:token],
|
614
617
|
'userid' => 'user_id',
|
615
618
|
'secret' => 'secret',
|
619
|
+
'type' => 'event',
|
620
|
+
'id' => 2,
|
616
621
|
'section' => :beavers,
|
617
|
-
'
|
618
|
-
'
|
619
|
-
'
|
620
|
-
'
|
621
|
-
'
|
622
|
+
'sectionid' => 1,
|
623
|
+
'badge_id' => 3,
|
624
|
+
'badge_version' => 2,
|
625
|
+
'column_id' => 1,
|
626
|
+
'column_data' => '',
|
627
|
+
'new_column_name' => '',
|
622
628
|
}
|
623
|
-
HTTParty.should_receive(:post).with(@badge_url, {:body => post_data}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"
|
629
|
+
HTTParty.should_receive(:post).with(@badge_url, {:body => post_data}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"status":true}'}) }
|
624
630
|
|
625
631
|
@attributes[:badges] = [Osm::Event::BadgeLink.new(
|
626
|
-
badge_key: 'test',
|
627
632
|
badge_type: :activity,
|
628
|
-
requirement_key: 'a_01',
|
629
633
|
badge_section: :beavers,
|
630
634
|
requirement_label: '',
|
631
635
|
data: '',
|
636
|
+
badge_name: 'Test badge',
|
637
|
+
badge_id: 3,
|
638
|
+
badge_version: 2,
|
639
|
+
requirement_id: 1,
|
632
640
|
)]
|
633
641
|
event = Osm::Event.create(@api, @attributes)
|
634
642
|
event.should_not be_nil
|
@@ -641,22 +649,26 @@ describe "Event" do
|
|
641
649
|
'token' => @CONFIGURATION[:api][:osm][:token],
|
642
650
|
'userid' => 'user_id',
|
643
651
|
'secret' => 'secret',
|
644
|
-
'
|
645
|
-
'
|
646
|
-
'
|
647
|
-
'
|
648
|
-
'
|
649
|
-
'
|
652
|
+
'type' => 'event',
|
653
|
+
'id' => 2,
|
654
|
+
'section' => :beavers,
|
655
|
+
'sectionid' => 1,
|
656
|
+
'badge_id' => 3,
|
657
|
+
'badge_version' => 2,
|
658
|
+
'column_id' => -2,
|
659
|
+
'column_data' => '1',
|
660
|
+
'new_column_name' => 'Label for added column',
|
650
661
|
}
|
651
|
-
HTTParty.should_receive(:post).with(@badge_url, {:body => post_data}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"
|
662
|
+
HTTParty.should_receive(:post).with(@badge_url, {:body => post_data}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"status":true}'}) }
|
652
663
|
|
653
664
|
@attributes[:badges] = [Osm::Event::BadgeLink.new(
|
654
|
-
badge_key: 'hikes',
|
655
665
|
badge_type: :staged,
|
656
|
-
|
657
|
-
badge_section: :staged,
|
666
|
+
badge_section: :beavers,
|
658
667
|
requirement_label: 'Label for added column',
|
659
668
|
data: '1',
|
669
|
+
badge_name: 'Test badge',
|
670
|
+
badge_id: 3,
|
671
|
+
badge_version: 2,
|
660
672
|
)]
|
661
673
|
event = Osm::Event.create(@api, @attributes)
|
662
674
|
event.should_not be_nil
|
@@ -669,22 +681,27 @@ describe "Event" do
|
|
669
681
|
'token' => @CONFIGURATION[:api][:osm][:token],
|
670
682
|
'userid' => 'user_id',
|
671
683
|
'secret' => 'secret',
|
672
|
-
'
|
673
|
-
'
|
674
|
-
'
|
675
|
-
'
|
676
|
-
'
|
677
|
-
'
|
684
|
+
'type' => 'event',
|
685
|
+
'id' => 2,
|
686
|
+
'section' => :beavers,
|
687
|
+
'sectionid' => 1,
|
688
|
+
'badge_id' => 3,
|
689
|
+
'badge_version' => 2,
|
690
|
+
'column_id' => 4,
|
691
|
+
'column_data' => '2',
|
692
|
+
'new_column_name' => '',
|
678
693
|
}
|
679
|
-
HTTParty.should_receive(:post).with(@badge_url, {:body => post_data}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"
|
694
|
+
HTTParty.should_receive(:post).with(@badge_url, {:body => post_data}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"status":true}'}) }
|
680
695
|
|
681
696
|
@attributes[:badges] = [Osm::Event::BadgeLink.new(
|
682
|
-
badge_key: 'nights',
|
683
697
|
badge_type: :staged,
|
684
|
-
|
685
|
-
badge_section: :staged,
|
698
|
+
badge_section: :beavers,
|
686
699
|
requirement_label: '',
|
687
700
|
data: '2',
|
701
|
+
badge_name: 'Test badge',
|
702
|
+
badge_id: 3,
|
703
|
+
badge_version: 2,
|
704
|
+
requirement_id: 4,
|
688
705
|
)]
|
689
706
|
event = Osm::Event.create(@api, @attributes)
|
690
707
|
event.should_not be_nil
|
@@ -836,7 +853,16 @@ describe "Event" do
|
|
836
853
|
:cost => '1.23',
|
837
854
|
:location => 'Somewhere',
|
838
855
|
:notes => 'none',
|
839
|
-
:badges => [Osm::Event::BadgeLink.new(
|
856
|
+
:badges => [Osm::Event::BadgeLink.new(
|
857
|
+
badge_type: :activity,
|
858
|
+
badge_section: :scouts,
|
859
|
+
requirement_label: 'A: Paint',
|
860
|
+
data: 'Yes',
|
861
|
+
badge_name: 'Artist',
|
862
|
+
badge_id: 3,
|
863
|
+
badge_version: 2,
|
864
|
+
requirement_id: 4,
|
865
|
+
)],
|
840
866
|
:columns => [],
|
841
867
|
:notepad => '',
|
842
868
|
:public_notepad => '',
|
@@ -851,44 +877,38 @@ describe "Event" do
|
|
851
877
|
end
|
852
878
|
|
853
879
|
it "Added" do
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
'
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
}],
|
868
|
-
}
|
869
|
-
HTTParty.should_receive(:post).with(url, {:body => post_data}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"ok":true,"error":"Update Error"}'}) }
|
870
|
-
|
871
|
-
@event.badges.push(Osm::Event::BadgeLink.new(badge_key: 'test2'))
|
880
|
+
badge = Osm::Event::BadgeLink.new(
|
881
|
+
badge_type: :activity,
|
882
|
+
badge_section: :scouts,
|
883
|
+
requirement_label: 'A: Draw',
|
884
|
+
data: 'Yes',
|
885
|
+
badge_name: 'Artist',
|
886
|
+
badge_id: 3,
|
887
|
+
badge_version: 2,
|
888
|
+
requirement_id: 6,
|
889
|
+
)
|
890
|
+
@event.should_receive(:add_badge_link).with(@api, badge) { true }
|
891
|
+
|
892
|
+
@event.badges.push(badge)
|
872
893
|
@event.update(@api).should be_true
|
873
894
|
end
|
874
895
|
|
875
896
|
it "Removed" do
|
876
|
-
url = 'https://www.onlinescoutmanager.co.uk/ext/
|
897
|
+
url = 'https://www.onlinescoutmanager.co.uk/ext/badges/records/index.php?action=deleteBadgeLink§ionid=1'
|
877
898
|
post_data = {
|
878
899
|
'apiid' => @CONFIGURATION[:api][:osm][:id],
|
879
900
|
'token' => @CONFIGURATION[:api][:osm][:token],
|
880
901
|
'userid' => 'user_id',
|
881
902
|
'secret' => 'secret',
|
882
|
-
'
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
}],
|
903
|
+
'section' => :scouts,
|
904
|
+
'sectionid' => 1,
|
905
|
+
'type' => 'event',
|
906
|
+
'id' => 2,
|
907
|
+
'badge_id' => 3,
|
908
|
+
'badge_version' => 2,
|
909
|
+
'column_id' => 4,
|
890
910
|
}
|
891
|
-
HTTParty.should_receive(:post).with(url, {:body => post_data}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"
|
911
|
+
HTTParty.should_receive(:post).with(url, {:body => post_data}) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"status":true}'}) }
|
892
912
|
|
893
913
|
@event.badges = []
|
894
914
|
@event.update(@api).should be_true
|
@@ -1215,13 +1235,13 @@ describe "Event" do
|
|
1215
1235
|
|
1216
1236
|
describe "API Strangeness" do
|
1217
1237
|
|
1218
|
-
it "
|
1238
|
+
it "Handles a non existant array when no events" do
|
1219
1239
|
data = '{"identifier":"eventid","label":"name"}'
|
1220
1240
|
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEvents§ionid=1&showArchived=true", :body => data, :content_type => 'application/json')
|
1221
1241
|
events = Osm::Event.get_for_section(@api, 1).should == []
|
1222
1242
|
end
|
1223
1243
|
|
1224
|
-
it "
|
1244
|
+
it "Handles missing config from OSM" do
|
1225
1245
|
events_body = '{"identifier":"eventid","label":"name","items":[{"eventid":"2","name":"An Event","startdate":"2001-02-03","enddate":"2001-02-05","starttime":"00:00:00","endtime":"12:00:00","cost":"0.00","location":"Somewhere","notes":"Notes","sectionid":1,"googlecalendar":null,"archived":"0","confdate":null,"allowchanges":"1","disablereminders":"1","attendancelimit":"3","limitincludesleaders":"1"}]}'
|
1226
1246
|
|
1227
1247
|
event_body = {
|