osm 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +29 -0
- data/lib/osm.rb +10 -2
- data/lib/osm/activity.rb +196 -40
- data/lib/osm/api.rb +27 -30
- data/lib/osm/api_access.rb +26 -11
- data/lib/osm/due_badges.rb +36 -22
- data/lib/osm/evening.rb +71 -34
- data/lib/osm/event.rb +30 -11
- data/lib/osm/grouping.rb +22 -8
- data/lib/osm/member.rb +59 -36
- data/lib/osm/register_data.rb +58 -0
- data/lib/osm/register_field.rb +39 -0
- data/lib/osm/role.rb +26 -9
- data/lib/osm/section.rb +95 -33
- data/lib/osm/term.rb +23 -8
- data/spec/osm/activity_spec.rb +34 -7
- data/spec/osm/api_access_spec.rb +9 -9
- data/spec/osm/api_spec.rb +7 -8
- data/spec/osm/due_badges_spec.rb +2 -2
- data/spec/osm/evening_spec.rb +30 -25
- data/spec/osm/event_spec.rb +2 -2
- data/spec/osm/grouping_spec.rb +1 -1
- data/spec/osm/member_spec.rb +6 -6
- data/spec/osm/register_data_spec.rb +34 -0
- data/spec/osm/register_field_spec.rb +23 -0
- data/spec/osm/role_spec.rb +33 -30
- data/spec/osm/section_spec.rb +61 -99
- data/spec/osm/term_spec.rb +40 -77
- data/version.rb +1 -1
- metadata +16 -12
data/spec/osm/due_badges_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
describe "DueBadge" do
|
5
5
|
|
6
|
-
it "Create" do
|
6
|
+
it "Create from API data" do
|
7
7
|
data = {
|
8
8
|
'pending' => {
|
9
9
|
'badge_name' => [
|
@@ -46,7 +46,7 @@ describe "DueBadge" do
|
|
46
46
|
}
|
47
47
|
}
|
48
48
|
}
|
49
|
-
db = Osm::DueBadges.
|
49
|
+
db = Osm::DueBadges.from_api(data)
|
50
50
|
|
51
51
|
db.empty?.should == false
|
52
52
|
db.descriptions.should == {:badge_name=>{:name=>"Badge Name", :section=>:cubs, :type=>:activity, :badge=>"badge_name"}, :cubs_core_participation=>{:name=>"Participation", :section=>:cubs, :type=>:core, :badge=>"participation"}}
|
data/spec/osm/evening_spec.rb
CHANGED
@@ -4,7 +4,23 @@ require 'date'
|
|
4
4
|
|
5
5
|
describe "Evening" do
|
6
6
|
|
7
|
-
|
7
|
+
before :each do
|
8
|
+
@attributes = {
|
9
|
+
:evening_id => 1,
|
10
|
+
:section_id => 2,
|
11
|
+
:title => 'Evening Name',
|
12
|
+
:notes_for_parents => 'Notes for parents',
|
13
|
+
:games => 'Games',
|
14
|
+
:pre_notes => 'Before',
|
15
|
+
:post_notes => 'After',
|
16
|
+
:leaders => 'Leaders',
|
17
|
+
:start_time => '19:00',
|
18
|
+
:end_time => '21:00',
|
19
|
+
:meeting_date => Date.new(2000, 01, 02),
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
it "Create from API data" do
|
8
24
|
data = {
|
9
25
|
'eveningid' => 1,
|
10
26
|
'sectionid' => 2,
|
@@ -24,7 +40,7 @@ describe "Evening" do
|
|
24
40
|
'title' => 'Activity Name',
|
25
41
|
'notes' => 'Notes',
|
26
42
|
}]
|
27
|
-
e = Osm::Evening.
|
43
|
+
e = Osm::Evening.from_api(data, activities)
|
28
44
|
|
29
45
|
e.evening_id.should == 1
|
30
46
|
e.section_id.should == 2
|
@@ -38,7 +54,6 @@ describe "Evening" do
|
|
38
54
|
e.end_time.should == '21:00'
|
39
55
|
e.meeting_date.should == Date.new(2000, 1, 2)
|
40
56
|
|
41
|
-
e.activities.frozen?.should be_true
|
42
57
|
ea = e.activities[0]
|
43
58
|
ea.activity_id.should == 2
|
44
59
|
ea.title.should == 'Activity Name'
|
@@ -47,7 +62,7 @@ describe "Evening" do
|
|
47
62
|
|
48
63
|
|
49
64
|
it "Raises exceptions when trying to set invalid times" do
|
50
|
-
e = Osm::Evening.new(
|
65
|
+
e = Osm::Evening.new(@attributes)
|
51
66
|
|
52
67
|
expect{ e.start_time = 'abcde' }.to raise_error(ArgumentError)
|
53
68
|
expect{ e.start_time = '24:00' }.to raise_error(ArgumentError)
|
@@ -64,27 +79,17 @@ describe "Evening" do
|
|
64
79
|
|
65
80
|
|
66
81
|
it "Creates the data for saving through the API" do
|
67
|
-
data =
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
'meetingdate' => '2000-01-02',
|
79
|
-
}
|
80
|
-
activities = [{
|
81
|
-
'eveningid' => 3,
|
82
|
-
'activityid' => 4,
|
83
|
-
'title' => 'Activity Name',
|
84
|
-
'notes' => 'Notes',
|
85
|
-
}]
|
86
|
-
e = Osm::Evening.new(data, activities)
|
87
|
-
e.data_for_saving.should == {
|
82
|
+
data = @attributes.merge(
|
83
|
+
:activities => [ Osm::Evening::Activity.new(
|
84
|
+
:activity_id => 4,
|
85
|
+
:title => 'Activity Name',
|
86
|
+
:notes => 'Notes',
|
87
|
+
) ]
|
88
|
+
)
|
89
|
+
|
90
|
+
e = Osm::Evening.new(data)
|
91
|
+
|
92
|
+
e.to_api.should == {
|
88
93
|
'eveningid' => 1,
|
89
94
|
'sectionid' => 2,
|
90
95
|
'meetingdate' => '2000-01-02',
|
data/spec/osm/event_spec.rb
CHANGED
@@ -4,7 +4,7 @@ require 'date'
|
|
4
4
|
|
5
5
|
describe "Event" do
|
6
6
|
|
7
|
-
it "Create" do
|
7
|
+
it "Create from API data" do
|
8
8
|
data = {
|
9
9
|
'eventid' => 1,
|
10
10
|
'sectionid' => 2,
|
@@ -17,7 +17,7 @@ describe "Event" do
|
|
17
17
|
'location' => 'Somewhere',
|
18
18
|
'notes' => 'None'
|
19
19
|
}
|
20
|
-
event = Osm::Event.
|
20
|
+
event = Osm::Event.from_api(data)
|
21
21
|
|
22
22
|
event.id.should == 1
|
23
23
|
event.section_id.should == 2
|
data/spec/osm/grouping_spec.rb
CHANGED
data/spec/osm/member_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
describe "Member" do
|
5
5
|
|
6
|
-
it "Create" do
|
6
|
+
it "Create from API data" do
|
7
7
|
data = {
|
8
8
|
'scoutid' => 1,
|
9
9
|
'sectionidO' => 2,
|
@@ -39,7 +39,7 @@ describe "Member" do
|
|
39
39
|
'patrolidO' => '3',
|
40
40
|
'patrolleaderO' => 0,
|
41
41
|
}
|
42
|
-
member = Osm::Member.
|
42
|
+
member = Osm::Member.from_api(data)
|
43
43
|
|
44
44
|
member.id.should == 1
|
45
45
|
member.section_id.should == 2
|
@@ -58,7 +58,7 @@ describe "Member" do
|
|
58
58
|
member.address2.should == ''
|
59
59
|
member.date_of_birth.should == Date.new(2000, 1, 2)
|
60
60
|
member.started.should == Date.new(2006, 1, 2)
|
61
|
-
member.
|
61
|
+
member.joining_in_years.should == 2
|
62
62
|
member.parents.should == 'John and Jane Doe'
|
63
63
|
member.notes.should == 'None'
|
64
64
|
member.medical.should == 'Nothing'
|
@@ -76,8 +76,8 @@ describe "Member" do
|
|
76
76
|
|
77
77
|
it "Provides member's full name" do
|
78
78
|
data = {
|
79
|
-
|
80
|
-
|
79
|
+
:first_name => 'First',
|
80
|
+
:last_name => 'Last',
|
81
81
|
}
|
82
82
|
member = Osm::Member.new(data)
|
83
83
|
|
@@ -88,7 +88,7 @@ describe "Member" do
|
|
88
88
|
|
89
89
|
it "Provides each part of age" do
|
90
90
|
data = {
|
91
|
-
|
91
|
+
:age => '06/07',
|
92
92
|
}
|
93
93
|
member = Osm::Member.new(data)
|
94
94
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
|
6
|
+
describe "Register Data" do
|
7
|
+
|
8
|
+
it "Create from API data" do
|
9
|
+
data = {
|
10
|
+
'scoutid' => '1',
|
11
|
+
'firstname' => 'A',
|
12
|
+
'lastname' => 'B',
|
13
|
+
'sectionid' => '2',
|
14
|
+
'patrolid' => '3',
|
15
|
+
'total' => 4,
|
16
|
+
'2012-01-10' => 'Yes',
|
17
|
+
'2012-01-24' => 'No',
|
18
|
+
}
|
19
|
+
|
20
|
+
rd = Osm::RegisterData.from_api(data)
|
21
|
+
|
22
|
+
rd.member_id.should == 1
|
23
|
+
rd.section_id.should == 2
|
24
|
+
rd.grouping_id.should == 3
|
25
|
+
rd.first_name.should == 'A'
|
26
|
+
rd.last_name.should == 'B'
|
27
|
+
rd.total.should == 4
|
28
|
+
rd.attendance.should == {
|
29
|
+
Date.new(2012, 01, 10) => 'Yes',
|
30
|
+
Date.new(2012, 01, 24) => 'No'
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
|
5
|
+
describe "Register Field" do
|
6
|
+
|
7
|
+
it "Create" do
|
8
|
+
data = {
|
9
|
+
'name' => 'Human name',
|
10
|
+
'field' => 'machine_name',
|
11
|
+
'formatter' => 'doneFormatter',
|
12
|
+
'width' => '110px',
|
13
|
+
'tooltip' => 'Tooltip'
|
14
|
+
}
|
15
|
+
|
16
|
+
field = Osm::RegisterField.from_api(data)
|
17
|
+
|
18
|
+
field.id.should == 'machine_name'
|
19
|
+
field.name.should == 'Human name'
|
20
|
+
field.tooltip.should == 'Tooltip'
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/spec/osm/role_spec.rb
CHANGED
@@ -3,9 +3,17 @@ require 'spec_helper'
|
|
3
3
|
require 'date'
|
4
4
|
|
5
5
|
|
6
|
+
class DummySection
|
7
|
+
attr_reader :name, :id
|
8
|
+
def initialize(options={})
|
9
|
+
options.each { |k,v| instance_variable_set("@#{k}", v) }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
|
6
14
|
describe "Role" do
|
7
15
|
|
8
|
-
it "Create" do
|
16
|
+
it "Create from API data" do
|
9
17
|
data = {
|
10
18
|
'sectionid' => 1,
|
11
19
|
'sectionname' => 'A Section',
|
@@ -16,7 +24,7 @@ describe "Role" do
|
|
16
24
|
'isDefault' => '1',
|
17
25
|
'permissions' => {}
|
18
26
|
}
|
19
|
-
role = Osm::Role.
|
27
|
+
role = Osm::Role.from_api(data)
|
20
28
|
|
21
29
|
role.section.id.should == 1
|
22
30
|
role.section.name.should == 'A Section'
|
@@ -26,28 +34,28 @@ describe "Role" do
|
|
26
34
|
|
27
35
|
|
28
36
|
it "Compares two matching roles" do
|
29
|
-
role1 = Osm::Role.new
|
30
|
-
role2 = Osm::Role.new
|
37
|
+
role1 = Osm::Role.new
|
38
|
+
role2 = Osm::Role.new
|
31
39
|
role1.should == role2
|
32
40
|
end
|
33
41
|
|
34
42
|
it "Compares two non-matching roles" do
|
35
|
-
role1 = Osm::Role.new(
|
36
|
-
role2 = Osm::Role.new(
|
43
|
+
role1 = Osm::Role.new(:section => DummySection.new(:id => 1))
|
44
|
+
role2 = Osm::Role.new(:section => DummySection.new(:id => 2))
|
37
45
|
|
38
46
|
role1.should_not == role2
|
39
47
|
end
|
40
48
|
|
41
49
|
|
42
50
|
it "Sorts by Group Name then section type (age order)" do
|
43
|
-
role1 = Osm::Role.
|
44
|
-
role2 = Osm::Role.
|
45
|
-
role3 = Osm::Role.
|
46
|
-
role4 = Osm::Role.
|
47
|
-
role5 = Osm::Role.
|
48
|
-
role6 = Osm::Role.
|
49
|
-
role7 = Osm::Role.
|
50
|
-
role8 = Osm::Role.
|
51
|
+
role1 = Osm::Role.from_api({'groupname' => 'Group A', 'sectionConfig' => '{}'})
|
52
|
+
role2 = Osm::Role.from_api({'groupname' => 'Group B', 'sectionConfig' => '{"sectionType":"beavers"}'})
|
53
|
+
role3 = Osm::Role.from_api({'groupname' => 'Group B', 'sectionConfig' => '{"sectionType":"cubs"}'})
|
54
|
+
role4 = Osm::Role.from_api({'groupname' => 'Group B', 'sectionConfig' => '{"sectionType":"scouts"}'})
|
55
|
+
role5 = Osm::Role.from_api({'groupname' => 'Group B', 'sectionConfig' => '{"sectionType":"explorers"}'})
|
56
|
+
role6 = Osm::Role.from_api({'groupname' => 'Group B', 'sectionConfig' => '{"sectionType":"waiting"}'})
|
57
|
+
role7 = Osm::Role.from_api({'groupname' => 'Group B', 'sectionConfig' => '{"sectionType":"adults"}'})
|
58
|
+
role8 = Osm::Role.from_api({'groupname' => 'Group C', 'sectionConfig' => '{}'})
|
51
59
|
|
52
60
|
data = [role8, role5, role3, role7, role2, role4, role1, role6]
|
53
61
|
data.sort.should == [role1, role2, role3, role4, role5, role6, role7, role8]
|
@@ -56,15 +64,13 @@ describe "Role" do
|
|
56
64
|
|
57
65
|
it "Provides a long name for the role" do
|
58
66
|
role = Osm::Role.new({
|
59
|
-
|
60
|
-
|
61
|
-
'groupname' => 'A Group',
|
67
|
+
:section => DummySection.new(:name => 'A Section'),
|
68
|
+
:group_name => 'A Group',
|
62
69
|
})
|
63
70
|
role.long_name.should == 'A Section (A Group)'
|
64
71
|
|
65
72
|
role = Osm::Role.new({
|
66
|
-
|
67
|
-
'sectionConfig' => '{}',
|
73
|
+
:section => DummySection.new(:name => 'A Section'),
|
68
74
|
})
|
69
75
|
role.long_name.should == 'A Section'
|
70
76
|
end
|
@@ -72,15 +78,13 @@ describe "Role" do
|
|
72
78
|
|
73
79
|
it "Provides a full name for the role" do
|
74
80
|
role = Osm::Role.new({
|
75
|
-
|
76
|
-
|
77
|
-
'groupname' => 'A Group',
|
81
|
+
:section => DummySection.new(:name => 'A Section'),
|
82
|
+
:group_name => 'A Group',
|
78
83
|
})
|
79
84
|
role.full_name.should == 'A Group A Section'
|
80
85
|
|
81
86
|
role = Osm::Role.new({
|
82
|
-
|
83
|
-
'sectionConfig' => '{}',
|
87
|
+
:section => DummySection.new(:name => 'A Section'),
|
84
88
|
})
|
85
89
|
role.full_name.should == 'A Section'
|
86
90
|
end
|
@@ -88,11 +92,10 @@ describe "Role" do
|
|
88
92
|
|
89
93
|
it "Allows interegation of the permissions hash" do
|
90
94
|
role = Osm::Role.new({
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
'administer' => 100
|
95
|
+
:permissions => {
|
96
|
+
:read_only => 10,
|
97
|
+
:read_write => 20,
|
98
|
+
:administer => 100
|
96
99
|
}
|
97
100
|
})
|
98
101
|
|
@@ -108,4 +111,4 @@ describe "Role" do
|
|
108
111
|
role.can_write?(:non_existant).should == false
|
109
112
|
end
|
110
113
|
|
111
|
-
end
|
114
|
+
end
|
data/spec/osm/section_spec.rb
CHANGED
@@ -11,13 +11,33 @@ describe "Section" do
|
|
11
11
|
@id = id
|
12
12
|
end
|
13
13
|
def <=>(another)
|
14
|
-
@id <=> another.
|
14
|
+
@id <=> another.id
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
|
19
|
+
before :each do
|
20
|
+
@attributes = {
|
21
|
+
:id => 1,
|
22
|
+
:name => 'Name',
|
23
|
+
:subscription_level => :silver,
|
24
|
+
:subscription_expires => (Date.today + 60).strftime('%Y-%m-%d'),
|
25
|
+
:sectionType => :cubs,
|
26
|
+
:numscouts => 10,
|
27
|
+
:hasUsedBadgeRecords => true,
|
28
|
+
:hasProgramme => true,
|
29
|
+
:wizard => false,
|
30
|
+
:columnNames => {},
|
31
|
+
:fields => {},
|
32
|
+
:intouch => {},
|
33
|
+
:mobFields => {},
|
34
|
+
:extraRecords => [],
|
35
|
+
:role => DummyRole.new(1)
|
36
|
+
}
|
37
|
+
end
|
19
38
|
|
20
|
-
|
39
|
+
|
40
|
+
it "Create from API data" do
|
21
41
|
data = {
|
22
42
|
'subscription_level' => '3',
|
23
43
|
'subscription_expires' => (Date.today + 60).strftime('%Y-%m-%d'),
|
@@ -27,10 +47,21 @@ describe "Section" do
|
|
27
47
|
'fields' => {},
|
28
48
|
'intouch' => {},
|
29
49
|
'mobFields' => {},
|
30
|
-
'extraRecords' => [
|
50
|
+
'extraRecords' => [
|
51
|
+
{
|
52
|
+
'name' => 'Name 1',
|
53
|
+
'extraid' => 1
|
54
|
+
}, [
|
55
|
+
'',
|
56
|
+
{
|
57
|
+
'name' => 'Name 2',
|
58
|
+
'extraid' => 2
|
59
|
+
}
|
60
|
+
]
|
61
|
+
]
|
31
62
|
}
|
32
63
|
role = DummyRole.new(1)
|
33
|
-
section = Osm::Section.
|
64
|
+
section = Osm::Section.from_api(1, 'Name', data, role)
|
34
65
|
|
35
66
|
section.id.should == 1
|
36
67
|
section.name.should == 'Name'
|
@@ -42,12 +73,15 @@ describe "Section" do
|
|
42
73
|
section.fields.should == {}
|
43
74
|
section.intouch_fields.should == {}
|
44
75
|
section.mobile_fields.should == {}
|
45
|
-
section.
|
76
|
+
section.flexi_records[0].id.should == 1
|
77
|
+
section.flexi_records[0].name.should == 'Name 1'
|
78
|
+
section.flexi_records[1].id.should == 2
|
79
|
+
section.flexi_records[1].name.should == 'Name 2'
|
46
80
|
section.role.should == role
|
47
81
|
end
|
48
82
|
|
49
83
|
it "Create has sensible defaults" do
|
50
|
-
section = Osm::Section.new
|
84
|
+
section = Osm::Section.new
|
51
85
|
|
52
86
|
section.subscription_level.should == :unknown
|
53
87
|
section.subscription_expires.should == nil
|
@@ -57,99 +91,41 @@ describe "Section" do
|
|
57
91
|
section.fields.should == {}
|
58
92
|
section.intouch_fields.should == {}
|
59
93
|
section.mobile_fields.should == {}
|
60
|
-
section.
|
94
|
+
section.flexi_records.should == []
|
61
95
|
end
|
62
96
|
|
63
97
|
|
64
98
|
it "Compares two matching sections" do
|
65
|
-
|
66
|
-
'subscription_level' => '3',
|
67
|
-
'subscription_expires' => (Date.today + 60).strftime('%Y-%m-%d'),
|
68
|
-
'sectionType' => 'cubs',
|
69
|
-
'numscouts' => '10',
|
70
|
-
'hasUsedBadgeRecords' => '1',
|
71
|
-
'hasProgramme' => true,
|
72
|
-
'wizard' => 'False',
|
73
|
-
'columnNames' => {},
|
74
|
-
'fields' => {},
|
75
|
-
'intouch' => {},
|
76
|
-
'mobFields' => {},
|
77
|
-
'extraRecords' => [],
|
78
|
-
}
|
79
|
-
role = DummyRole.new(1)
|
80
|
-
section1 = Osm::Section.new(1, 'Name', data, role)
|
99
|
+
section1 = Osm::Section.new(@attributes)
|
81
100
|
section2 = section1.clone
|
82
101
|
|
83
102
|
section1.should == section2
|
84
103
|
end
|
85
104
|
|
86
105
|
it "Compares two non-matching sections" do
|
87
|
-
|
88
|
-
|
89
|
-
'subscription_expires' => (Date.today + 60).strftime('%Y-%m-%d'),
|
90
|
-
'sectionType' => 'cubs',
|
91
|
-
'numscouts' => '10',
|
92
|
-
'hasUsedBadgeRecords' => '1',
|
93
|
-
'hasProgramme' => true,
|
94
|
-
'wizard' => 'False',
|
95
|
-
'columnNames' => {},
|
96
|
-
'fields' => {},
|
97
|
-
'intouch' => {},
|
98
|
-
'mobFields' => {},
|
99
|
-
'extraRecords' => [],
|
100
|
-
}
|
101
|
-
role = DummyRole.new(1)
|
102
|
-
section1 = Osm::Section.new(1, 'Name', data, role)
|
103
|
-
section2 = Osm::Section.new(2, 'Name', data, role)
|
106
|
+
section1 = Osm::Section.new(@attributes)
|
107
|
+
section2 = Osm::Section.new(@attributes.merge(:id => 2))
|
104
108
|
|
105
109
|
section1.should_not == section2
|
106
110
|
end
|
107
111
|
|
108
112
|
|
109
113
|
it "Sorts by role" do
|
110
|
-
|
111
|
-
|
112
|
-
'subscription_expires' => (Date.today + 60).strftime('%Y-%m-%d'),
|
113
|
-
'sectionType' => 'cubs',
|
114
|
-
'numscouts' => '10',
|
115
|
-
'hasUsedBadgeRecords' => '1',
|
116
|
-
'hasProgramme' => true,
|
117
|
-
'wizard' => 'False',
|
118
|
-
'columnNames' => {},
|
119
|
-
'fields' => {},
|
120
|
-
'intouch' => {},
|
121
|
-
'mobFields' => {},
|
122
|
-
'extraRecords' => [],
|
123
|
-
}
|
124
|
-
section1 = Osm::Section.new(1, 'Name', data, DummyRole.new(1))
|
125
|
-
section2 = Osm::Section.new(1, 'Name', data, DummyRole.new(2))
|
114
|
+
section1 = Osm::Section.new(@attributes.merge(:role => DummyRole.new(1)))
|
115
|
+
section2 = Osm::Section.new(@attributes.merge(:role => DummyRole.new(2)))
|
126
116
|
|
127
117
|
[section2, section1].sort.should == [section1, section2]
|
128
118
|
end
|
129
119
|
|
130
120
|
|
131
121
|
it "Correctly works out the section type" do
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
'columnNames' => {},
|
140
|
-
'fields' => {},
|
141
|
-
'intouch' => {},
|
142
|
-
'mobFields' => {},
|
143
|
-
'extraRecords' => [],
|
144
|
-
}
|
145
|
-
|
146
|
-
unknown = Osm::Section.new(1, 'Name', data, DummyRole.new(1))
|
147
|
-
beavers = Osm::Section.new(2, 'Name', data.merge('sectionType' => 'beavers'), DummyRole.new(2))
|
148
|
-
cubs = Osm::Section.new(3, 'Name', data.merge('sectionType' => 'cubs'), DummyRole.new(3))
|
149
|
-
scouts = Osm::Section.new(4, 'Name', data.merge('sectionType' => 'scouts'), DummyRole.new(4))
|
150
|
-
explorers = Osm::Section.new(5, 'Name', data.merge('sectionType' => 'explorers'), DummyRole.new(5))
|
151
|
-
adults = Osm::Section.new(6, 'Name', data.merge('sectionType' => 'adults'), DummyRole.new(6))
|
152
|
-
waiting = Osm::Section.new(7, 'Name', data.merge('sectionType' => 'waiting'), DummyRole.new(7))
|
122
|
+
unknown = Osm::Section.new(@attributes.merge(:id => 1, :role => DummyRole.new(1)))
|
123
|
+
beavers = Osm::Section.new(@attributes.merge(:id => 2, :type => :beavers, :role => DummyRole.new(2)))
|
124
|
+
cubs = Osm::Section.new(@attributes.merge(:id => 3, :type => :cubs, :role => DummyRole.new(3)))
|
125
|
+
scouts = Osm::Section.new(@attributes.merge(:id => 4, :type => :scouts, :role => DummyRole.new(4)))
|
126
|
+
explorers = Osm::Section.new(@attributes.merge(:id => 5, :type => :explorers, :role => DummyRole.new(5)))
|
127
|
+
adults = Osm::Section.new(@attributes.merge(:id => 6, :type => :adults, :role => DummyRole.new(6)))
|
128
|
+
waiting = Osm::Section.new(@attributes.merge(:id => 7, :type => :waiting, :role => DummyRole.new(7)))
|
153
129
|
|
154
130
|
{:beavers => beavers, :cubs => cubs, :scouts => scouts, :explorers => explorers, :adults => adults, :waiting => waiting, :unknwoon => unknown}.each do |section_type, section|
|
155
131
|
[:beavers, :cubs, :scouts, :explorers, :adults, :waiting].each do |type|
|
@@ -160,27 +136,13 @@ describe "Section" do
|
|
160
136
|
|
161
137
|
|
162
138
|
it "Correctly works out if the section is a youth section" do
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
'columnNames' => {},
|
171
|
-
'fields' => {},
|
172
|
-
'intouch' => {},
|
173
|
-
'mobFields' => {},
|
174
|
-
'extraRecords' => [],
|
175
|
-
}
|
176
|
-
|
177
|
-
unknown = Osm::Section.new(1, 'Name', data, DummyRole.new(1))
|
178
|
-
beavers = Osm::Section.new(2, 'Name', data.merge('sectionType' => 'beavers'), DummyRole.new(2))
|
179
|
-
cubs = Osm::Section.new(3, 'Name', data.merge('sectionType' => 'cubs'), DummyRole.new(3))
|
180
|
-
scouts = Osm::Section.new(4, 'Name', data.merge('sectionType' => 'scouts'), DummyRole.new(4))
|
181
|
-
explorers = Osm::Section.new(5, 'Name', data.merge('sectionType' => 'explorers'), DummyRole.new(5))
|
182
|
-
adults = Osm::Section.new(6, 'Name', data.merge('sectionType' => 'adults'), DummyRole.new(6))
|
183
|
-
waiting = Osm::Section.new(7, 'Name', data.merge('sectionType' => 'waiting'), DummyRole.new(7))
|
139
|
+
unknown = Osm::Section.new(@attributes.merge(:id => 1, :role => DummyRole.new(1)))
|
140
|
+
beavers = Osm::Section.new(@attributes.merge(:id => 2, :type => :beavers, :role => DummyRole.new(2)))
|
141
|
+
cubs = Osm::Section.new(@attributes.merge(:id => 3, :type => :cubs, :role => DummyRole.new(3)))
|
142
|
+
scouts = Osm::Section.new(@attributes.merge(:id => 4, :type => :scouts, :role => DummyRole.new(4)))
|
143
|
+
explorers = Osm::Section.new(@attributes.merge(:id => 5, :type => :explorers, :role => DummyRole.new(5)))
|
144
|
+
adults = Osm::Section.new(@attributes.merge(:id => 6, :type => :adults, :role => DummyRole.new(6)))
|
145
|
+
waiting = Osm::Section.new(@attributes.merge(:id => 7, :type => :waiting, :role => DummyRole.new(7)))
|
184
146
|
|
185
147
|
[beavers, cubs, scouts, explorers].each do |section|
|
186
148
|
section.youth_section?.should == true
|
@@ -190,4 +152,4 @@ describe "Section" do
|
|
190
152
|
end
|
191
153
|
end
|
192
154
|
|
193
|
-
end
|
155
|
+
end
|