discourse_api 0.6.1 → 0.6.2
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/CHANGELOG.md +5 -0
- data/lib/discourse_api/api/params.rb +4 -10
- data/lib/discourse_api/version.rb +1 -1
- data/spec/discourse_api/api/params_spec.rb +13 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8d1504d9f6215e61f1b9038809f8663eaa566b8
|
4
|
+
data.tar.gz: b4ed50ba139c359d2a33b96a26b9c851431abb9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 414204490efeb376d200c2fce194d031d383af3da1f59825d3268359c480264d7f36468a9c2f1476fec3eaa41e1fa87f925661430bea225503cb7062136166f6
|
7
|
+
data.tar.gz: ce5ca8d555c8d0a8f4250c8597870ae64c8e4604bfa3c00322dce468214c0e6dea87e3ed59d8802c230607ef961e10872f679f56e4195e59b52539484890b1ce
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
|
5
|
+
## [0.6.2] - 2015-12-02
|
6
|
+
### Fixed
|
7
|
+
- `API::Params` will not work correctly when both optional and defaults are
|
8
|
+
specified
|
9
|
+
|
5
10
|
## [0.6.1] - 2015-11-28
|
6
11
|
### Fixed
|
7
12
|
- typo in topic_posts method
|
@@ -38,18 +38,12 @@ module DiscourseApi
|
|
38
38
|
raise ArgumentError.new("#{k} is required but not specified") unless h[k]
|
39
39
|
end
|
40
40
|
|
41
|
-
|
42
|
-
if @
|
43
|
-
|
44
|
-
else
|
45
|
-
@optional.each do |k|
|
46
|
-
h[k] = @args[k] if @args.include?(k)
|
47
|
-
end
|
48
|
-
h
|
49
|
-
end
|
41
|
+
@optional.each do |k|
|
42
|
+
h[k] = @args[k] if @args.include?(k)
|
43
|
+
end
|
50
44
|
|
51
45
|
@defaults.each do |k,v|
|
52
|
-
h[k] =
|
46
|
+
@args.key?(k) ? h[k] = @args[k] : h[k] = v
|
53
47
|
end
|
54
48
|
|
55
49
|
h
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe DiscourseApi::API::Params do
|
4
4
|
def params_for(h)
|
5
|
-
DiscourseApi::API::Params.new(h).required(:r1).optional(:o1, :o2)
|
5
|
+
DiscourseApi::API::Params.new(h).required(:r1).optional(:o1, :o2).default(d1: "default")
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should raise on missing required params" do
|
@@ -17,4 +17,16 @@ describe DiscourseApi::API::Params do
|
|
17
17
|
expect(params_for({r1: "test", o2: nil}).to_h).to include(:o2)
|
18
18
|
end
|
19
19
|
|
20
|
+
it "should include default params when defined but not provided" do
|
21
|
+
expect(params_for({r1: "test"}).to_h).to include(d1: "default")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should include default params when defined and provided" do
|
25
|
+
expect(params_for({r1: "test", d1: "override"}).to_h).to include(d1: "override")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should include optional and default params when defined and provided" do
|
29
|
+
expect(params_for({r1: "test", o1: "optional", d1: "override"}).to_h).to include(o1: "optional", d1: "override")
|
30
|
+
end
|
31
|
+
|
20
32
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: discourse_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-12-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|