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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03839d5965051fc89e305bbfab286efdc3b0692e
4
- data.tar.gz: e6794d1f02adddab8a2429c2e3c1eb95ab98f37a
3
+ metadata.gz: f8d1504d9f6215e61f1b9038809f8663eaa566b8
4
+ data.tar.gz: b4ed50ba139c359d2a33b96a26b9c851431abb9c
5
5
  SHA512:
6
- metadata.gz: 14e05fdda3649ccb71c7cc350f4e056237f5803af5450adb6fc4b1cf5d108967509a6713bb277c3e2b681957f2af7e4b21dc25df7506b3774a2220427ddeb61c
7
- data.tar.gz: 9b5a76da916d2b54a1d6d489ca044396db57c2f12a68492a4cc8d39455af7450f27b1b55d645ce909115f8b071a002beabe8996d2308f43d43b6ec04f2bac554
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
- h =
42
- if @optional.length == 0
43
- @args.dup
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] = v unless h.key?(k)
46
+ @args.key?(k) ? h[k] = @args[k] : h[k] = v
53
47
  end
54
48
 
55
49
  h
@@ -1,3 +1,3 @@
1
1
  module DiscourseApi
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
@@ -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.1
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-11-28 00:00:00.000000000 Z
13
+ date: 2015-12-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday