neutral 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/assets/stylesheets/neutral/index.css +2 -2
- data/app/views/neutral/votes/create.js.erb +4 -4
- data/app/views/neutral/votes/destroy.js.erb +4 -4
- data/app/views/neutral/votes/update.js.erb +4 -4
- data/lib/neutral/version.rb +1 -1
- data/lib/neutral/voting_builder/elements/span.rb +3 -3
- data/neutral.gemspec +2 -2
- data/spec/voting_builder/builder_spec.rb +3 -5
- data/spec/voting_builder/elements/span_spec.rb +9 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28bba1188ad74ced81d86d0eb403f409096a47fa
|
4
|
+
data.tar.gz: c8f8894572d72f30ebfb941e8d94762d5779f5da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc745f228aad30bd887a3e4d821f2eae223165bb4186c3ed6bcd6c149976a954fe07dbe89f475abe3d253c058924352196c38761ec136fa13c7a239c68c62dfc
|
7
|
+
data.tar.gz: 317ec623838b2d8e8c15a7dcad67515667280e25b65ae7050fbbd57f3803f8a08c9ed674a544d2ab6896818e8ca1946ab0fca025f39bdbb4bea2706545f52b26
|
data/Gemfile.lock
CHANGED
@@ -29,11 +29,11 @@ div.neutral span {
|
|
29
29
|
display: inline;
|
30
30
|
}
|
31
31
|
|
32
|
-
div.neutral span
|
32
|
+
div.neutral span.positive {
|
33
33
|
color: green;
|
34
34
|
}
|
35
35
|
|
36
|
-
div.neutral span
|
36
|
+
div.neutral span.negative {
|
37
37
|
color: red;
|
38
38
|
}
|
39
39
|
|
@@ -2,11 +2,11 @@ $(document).ready(function() {
|
|
2
2
|
|
3
3
|
neutral = $("div.neutral").find("<%= by_url %>").parent();
|
4
4
|
|
5
|
-
neutral.find("span
|
6
|
-
neutral.find("span
|
7
|
-
neutral.find("span
|
5
|
+
neutral.find("span.positive").html("<%= voting.positive.nonzero? %>");
|
6
|
+
neutral.find("span.negative").html("<%= voting.negative.nonzero? %>");
|
7
|
+
neutral.find("span.difference").html("<%= voting.difference.nonzero?.try(:abs) %>");
|
8
8
|
|
9
|
-
neutral.find("span
|
9
|
+
neutral.find("span.difference").attr("class", "<%= "difference #{voting.difference > 0 ? 'positive' : 'negative'}" %>");
|
10
10
|
|
11
11
|
<% if vote.voter_id && Neutral.config.can_change %>
|
12
12
|
|
@@ -7,11 +7,11 @@ $(document).ready(function() {
|
|
7
7
|
neutral.find("a.positive").attr('href', '<%= votes_path(1) %>');
|
8
8
|
neutral.find("a.negative").attr('href', '<%= votes_path(0) %>');
|
9
9
|
|
10
|
-
neutral.find("span
|
11
|
-
neutral.find("span
|
12
|
-
neutral.find("span
|
10
|
+
neutral.find("span.positive").html("<%= voting.positive.nonzero? %>");
|
11
|
+
neutral.find("span.negative").html("<%= voting.negative.nonzero? %>");
|
12
|
+
neutral.find("span.difference").html("<%= voting.difference.nonzero?.try(:abs) %>");
|
13
13
|
|
14
|
-
neutral.find("span
|
14
|
+
neutral.find("span.difference").attr("class", "<%= "difference #{voting.difference > 0 ? 'positive' : 'negative'}" %>");
|
15
15
|
|
16
16
|
neutral.find("a.remove").remove();
|
17
17
|
|
@@ -2,10 +2,10 @@ $(document).ready(function() {
|
|
2
2
|
|
3
3
|
neutral = $("div.neutral").find("<%= by_url %>").parent();
|
4
4
|
|
5
|
-
neutral.find("span
|
6
|
-
neutral.find("span
|
7
|
-
neutral.find("span
|
5
|
+
neutral.find("span.positive").html("<%= voting.positive.nonzero? %>");
|
6
|
+
neutral.find("span.negative").html("<%= voting.negative.nonzero? %>");
|
7
|
+
neutral.find("span.difference").html("<%= voting.difference.nonzero?.try(:abs) %>");
|
8
8
|
|
9
|
-
neutral.find("span
|
9
|
+
neutral.find("span.difference").attr("class", "<%= "difference #{voting.difference > 0 ? 'positive' : 'negative'}" %>");
|
10
10
|
|
11
11
|
});
|
data/lib/neutral/version.rb
CHANGED
@@ -15,19 +15,19 @@ module Neutral
|
|
15
15
|
|
16
16
|
class Positive < Span
|
17
17
|
def to_s
|
18
|
-
content_tag :span, total,
|
18
|
+
content_tag :span, total, class: 'positive'
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
class Negative < Span
|
23
23
|
def to_s
|
24
|
-
content_tag :span, total,
|
24
|
+
content_tag :span, total, class: 'negative'
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
class Difference < Span
|
29
29
|
def to_s
|
30
|
-
content_tag :span, total.try(:abs), class: color
|
30
|
+
content_tag :span, total.try(:abs), class: "difference #{color}"
|
31
31
|
end
|
32
32
|
|
33
33
|
private
|
data/neutral.gemspec
CHANGED
@@ -15,8 +15,8 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.test_files = `git ls-files -- spec/**/*`.split("\n")
|
16
16
|
|
17
17
|
s.add_dependency "rails", "~> 4.0.0"
|
18
|
-
|
19
|
-
|
18
|
+
s.add_dependency "font-awesome-rails", "~> 4.0.3.1"
|
19
|
+
s.add_dependency "jquery-rails"
|
20
20
|
|
21
21
|
s.add_development_dependency "sqlite3"
|
22
22
|
s.add_development_dependency "simplecov"
|
@@ -9,18 +9,16 @@ describe Neutral::VotingBuilder::Builder, type: :feature do
|
|
9
9
|
subject { Neutral::VotingBuilder::Builder.new(voteable, {}).build }
|
10
10
|
|
11
11
|
it { should have_selector "div.neutral" }
|
12
|
-
it { should have_selector "span
|
12
|
+
it { should have_selector "span.positive" }
|
13
13
|
it { should have_selector "a.positive" }
|
14
14
|
it { should have_selector "a.negative" }
|
15
|
-
it { should have_selector "span
|
15
|
+
it { should have_selector "span.negative" }
|
16
16
|
end
|
17
17
|
|
18
18
|
context "with difference" do
|
19
19
|
subject { Neutral::VotingBuilder::Builder.new(voteable, difference: true).build }
|
20
20
|
|
21
|
-
it { should have_selector "span
|
22
|
-
it { should_not have_selector "span#positive" }
|
23
|
-
it { should_not have_selector "span#negative" }
|
21
|
+
it { should have_selector "span.difference" }
|
24
22
|
end
|
25
23
|
|
26
24
|
describe "remove link" do
|
@@ -7,10 +7,11 @@ describe Span, type: :feature do
|
|
7
7
|
describe span do
|
8
8
|
describe "#to_s" do
|
9
9
|
let(:total) { rand(100) + 1 }
|
10
|
+
let(:klass) { span.to_s.demodulize.downcase }
|
10
11
|
|
11
12
|
subject { Capybara.string span.new(total).to_s }
|
12
13
|
|
13
|
-
it { should have_selector("span
|
14
|
+
it { should have_selector("span.#{klass}") }
|
14
15
|
|
15
16
|
it "has value of given total" do
|
16
17
|
subject.find("span").text.should == total.to_s
|
@@ -24,20 +25,24 @@ describe Span, type: :feature do
|
|
24
25
|
end
|
25
26
|
|
26
27
|
describe Span::Difference do
|
28
|
+
def difference_element(total)
|
29
|
+
Capybara.string(Span::Difference.new(total).to_s).find("span")
|
30
|
+
end
|
31
|
+
|
27
32
|
describe "#to_s" do
|
28
33
|
let(:positive) { rand(100) + 1 }
|
29
34
|
let(:negative) { -(rand(100) + 1) }
|
30
35
|
|
31
36
|
it "has absolute value of total" do
|
32
|
-
|
37
|
+
difference_element(negative).text.to_i.should > 0
|
33
38
|
end
|
34
39
|
|
35
40
|
it "has 'positive' class when positive value of total is passed" do
|
36
|
-
|
41
|
+
difference_element(positive)[:class].should include("positive")
|
37
42
|
end
|
38
43
|
|
39
44
|
it "has 'negative' class when negative value of total is passed" do
|
40
|
-
|
45
|
+
difference_element(negative)[:class].should include("negative")
|
41
46
|
end
|
42
47
|
end
|
43
48
|
end
|