pugin 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/views/pugin/components/_navigation-letter.haml +1 -1
- data/app/views/pugin/components/_status.haml +5 -1
- data/config/locales/en.yml +1 -0
- data/lib/pugin/feature/bandiera.rb +10 -0
- data/lib/pugin/version.rb +1 -1
- data/lib/pugin/view_helpers.rb +3 -4
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +36 -0
- data/spec/dummy/log/test.log +1386 -0
- data/spec/lib/pugin/feature/bandiera_spec.rb +29 -47
- data/spec/views/pugin/components/_navigation-letter.html.haml_spec.rb +4 -16
- data/spec/views/pugin/components/_status.html.haml_spec.rb +31 -0
- metadata +2 -2
@@ -1,52 +1,34 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'pugin/feature/bandiera'
|
3
3
|
|
4
|
-
describe 'The bandiera client' do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
before :each do
|
34
|
-
Pugin::Feature::Bandiera.instance_variable_set(:@features, {'show-register' => true})
|
35
|
-
end
|
36
|
-
|
37
|
-
it "returns the value of show-dissolution in the Bandiera database if it exists" do
|
38
|
-
expect(Pugin::Feature::Bandiera.register_to_vote?).to equal(true)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'when the feature does not exist in Bandiera' do
|
43
|
-
|
44
|
-
before :each do
|
45
|
-
Pugin::Feature::Bandiera.instance_variable_set(:@features, {})
|
46
|
-
end
|
47
|
-
|
48
|
-
it "returns false because the feature value is nil" do
|
49
|
-
expect(Pugin::Feature::Bandiera.register_to_vote?).to equal(false)
|
4
|
+
describe 'The bandiera client feature set' do
|
5
|
+
|
6
|
+
method_hash = {
|
7
|
+
'show-dissolution': :dissolution?,
|
8
|
+
'show-register': :register_to_vote?,
|
9
|
+
'show-election': :election?,
|
10
|
+
'show-post-election': :post_election?
|
11
|
+
}
|
12
|
+
|
13
|
+
method_hash.each do |flag_name, method_name|
|
14
|
+
context flag_name do
|
15
|
+
context 'when the feature exists in Bandiera' do
|
16
|
+
before :each do
|
17
|
+
Pugin::Feature::Bandiera.instance_variable_set(:@features, {"#{flag_name}" => true})
|
18
|
+
end
|
19
|
+
|
20
|
+
it "returns the value of #{flag_name} in the Bandiera database if it exists" do
|
21
|
+
expect(Pugin::Feature::Bandiera.send(method_name)).to equal(true)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
context 'when the feature does not exist in Bandiera' do
|
25
|
+
before :each do
|
26
|
+
Pugin::Feature::Bandiera.instance_variable_set(:@features, {})
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns false because the feature value is nil" do
|
30
|
+
expect(Pugin::Feature::Bandiera.send(method_name)).to equal(false)
|
31
|
+
end
|
50
32
|
end
|
51
33
|
end
|
52
34
|
end
|
@@ -62,4 +44,4 @@ describe 'The bandiera client' do
|
|
62
44
|
expect(@features).to equal(nil)
|
63
45
|
end
|
64
46
|
end
|
65
|
-
end
|
47
|
+
end
|
@@ -51,23 +51,11 @@ describe 'pugin/components/_navigation-letter.html.haml', type: :view do
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
render partial: 'pugin/components/navigation-letter', locals: { route_symbol: :party_members_letter_path, primary_id: @primary_id }
|
58
|
-
end
|
59
|
-
|
60
|
-
('a'..'z').each do |letter|
|
61
|
-
it "renders a navigation link for /parties/1234/a-z/#{letter}" do
|
62
|
-
expect(rendered).to include("<a data-atoz-see=\"true\" href=\"/parties/1234/members/a-z/#{letter}\">#{letter}</a>")
|
63
|
-
end
|
54
|
+
context 'and with route arguments' do
|
55
|
+
before :each do
|
56
|
+
render partial: 'pugin/components/navigation-letter', locals: { route_symbol: :house_party_members_letter_path, route_args:[@primary_id,@secondary_id] }
|
64
57
|
end
|
65
|
-
end
|
66
58
|
|
67
|
-
context 'and both a primary and secondary id' do
|
68
|
-
before :each do
|
69
|
-
render partial: 'pugin/components/navigation-letter', locals: { route_symbol: :house_party_members_letter_path, primary_id: @primary_id, secondary_id: @secondary_id }
|
70
|
-
end
|
71
59
|
('a'..'z').each do |letter|
|
72
60
|
it "renders a navigation link for /houses/1234/parties/5678/members/a-z/#{letter}" do
|
73
61
|
expect(rendered).to include("<a data-atoz-see=\"true\" href=\"/houses/1234/parties/5678/members/a-z/#{letter}\">#{letter}</a>")
|
@@ -78,7 +66,7 @@ describe 'pugin/components/_navigation-letter.html.haml', type: :view do
|
|
78
66
|
context "doesn't render links for empty letters" do
|
79
67
|
before :each do
|
80
68
|
@letters = []
|
81
|
-
render partial: 'pugin/components/navigation-letter', locals: { route_symbol: :party_members_letter_path,
|
69
|
+
render partial: 'pugin/components/navigation-letter', locals: { route_symbol: :party_members_letter_path, route_args: [@primary_id] }
|
82
70
|
end
|
83
71
|
|
84
72
|
('a'..'z').each do |letter|
|
@@ -8,6 +8,7 @@ describe 'pugin/components/_status.html.haml', type: :view do
|
|
8
8
|
before :each do
|
9
9
|
allow(Pugin::Feature::Bandiera).to receive(:dissolution?).and_return(false)
|
10
10
|
allow(Pugin::Feature::Bandiera).to receive(:register_to_vote?).and_return(false)
|
11
|
+
allow(Pugin::Feature::Bandiera).to receive(:election?).and_return(false)
|
11
12
|
end
|
12
13
|
|
13
14
|
it 'renders a message not related to the dissolution' do
|
@@ -85,4 +86,34 @@ DATA
|
|
85
86
|
end
|
86
87
|
end
|
87
88
|
|
89
|
+
context 'while on election day' do
|
90
|
+
|
91
|
+
before :each do
|
92
|
+
allow(Pugin::Feature::Bandiera).to receive(:dissolution?).and_return(false)
|
93
|
+
allow(Pugin::Feature::Bandiera).to receive(:register_to_vote?).and_return(false)
|
94
|
+
allow(Pugin::Feature::Bandiera).to receive(:election?).and_return(true)
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'renders a message that reminds the user of the general election date' do
|
98
|
+
render partial: 'pugin/components/status', locals: { status: nil }
|
99
|
+
|
100
|
+
expect(response).to eq(
|
101
|
+
<<DATA
|
102
|
+
<div class='highlight--status highlight--default'>
|
103
|
+
<div class='container'>
|
104
|
+
<p>
|
105
|
+
This is a test website, so may be inaccurate.
|
106
|
+
<a href='http://www.smartsurvey.co.uk/s/ukparliament-beta-website-feedback/' target='_blank' title='website opens in a new window'>Give feedback</a>
|
107
|
+
to help improve it.
|
108
|
+
Thursday 8 June is election day, find out
|
109
|
+
<a href='http://www.parliament.uk/get-involved/elections/voting/' target='_blank' title='website opens in a new window'>how to vote</a>.
|
110
|
+
</p>
|
111
|
+
</div>
|
112
|
+
</div>
|
113
|
+
DATA
|
114
|
+
)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
|
88
119
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Rayner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|