kintone 0.0.4 → 0.0.5

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +26 -0
  3. data/.travis.yml +4 -0
  4. data/Guardfile +10 -0
  5. data/README.md +35 -13
  6. data/Rakefile +9 -1
  7. data/kintone.gemspec +17 -14
  8. data/lib/kintone.rb +2 -2
  9. data/lib/kintone/api.rb +36 -22
  10. data/lib/kintone/api/guest.rb +16 -8
  11. data/lib/kintone/command.rb +11 -2
  12. data/lib/kintone/command/app_acl.rb +4 -8
  13. data/lib/kintone/command/field_acl.rb +4 -8
  14. data/lib/kintone/command/form.rb +4 -8
  15. data/lib/kintone/command/record.rb +6 -10
  16. data/lib/kintone/command/record_acl.rb +4 -8
  17. data/lib/kintone/command/records.rb +11 -15
  18. data/lib/kintone/command/space.rb +15 -0
  19. data/lib/kintone/command/space_body.rb +11 -0
  20. data/lib/kintone/command/template_space.rb +12 -0
  21. data/lib/kintone/version.rb +1 -1
  22. data/spec/kintone/api/guest_spec.rb +134 -0
  23. data/spec/kintone/api_spec.rb +176 -0
  24. data/spec/kintone/command/app_acl_spec.rb +28 -0
  25. data/spec/kintone/command/field_acl_spec.rb +28 -0
  26. data/spec/kintone/command/form_spec.rb +26 -0
  27. data/spec/kintone/command/record_acl_spec.rb +28 -0
  28. data/spec/kintone/command/record_spec.rb +93 -0
  29. data/spec/kintone/command/records_spec.rb +169 -0
  30. data/spec/kintone/command/space_body_spec.rb +28 -0
  31. data/spec/kintone/command/space_spec.rb +53 -0
  32. data/spec/kintone/command/template_space_spec.rb +41 -0
  33. metadata +75 -36
  34. data/spec/api/guest_spec.rb +0 -54
  35. data/spec/api_spec.rb +0 -148
  36. data/spec/command/app_acl_spec.rb +0 -28
  37. data/spec/command/field_acl_spec.rb +0 -28
  38. data/spec/command/form_spec.rb +0 -25
  39. data/spec/command/record_acl_spec.rb +0 -28
  40. data/spec/command/record_spec.rb +0 -92
  41. data/spec/command/records_spec.rb +0 -162
@@ -1,28 +0,0 @@
1
- require 'spec_helper'
2
- require 'kintone/command/app_acl'
3
- require 'kintone/api'
4
-
5
- describe Kintone::Command::AppAcl do
6
- let(:target) { Kintone::Command::AppAcl.new(api) }
7
- let(:api) { Kintone::Api.new("example.cybozu.com", "Administrator", "cybozu") }
8
-
9
- describe "#update" do
10
- subject { target.update(app, rights) }
11
-
12
- context "" do
13
- before(:each) do
14
- stub_request(
15
- :put,
16
- "https://example.cybozu.com/k/v1/app/acl.json"
17
- ).
18
- with(:body => {"app" => 1, "rights" => {"p1" => "abc", "p2" => "def"}}.to_json).
19
- to_return(:body => "{}", :status => 200)
20
- end
21
-
22
- let(:app) { 1 }
23
- let(:rights) { {"p1" => "abc", "p2" => "def"} }
24
-
25
- it { expect(subject).to eq({}) }
26
- end
27
- end
28
- end
@@ -1,28 +0,0 @@
1
- require 'spec_helper'
2
- require 'kintone/command/field_acl'
3
- require 'kintone/api'
4
-
5
- describe Kintone::Command::FieldAcl do
6
- let(:target) { Kintone::Command::FieldAcl.new(api) }
7
- let(:api) { Kintone::Api.new("example.cybozu.com", "Administrator", "cybozu") }
8
-
9
- describe "#update" do
10
- subject { target.update(id, rights) }
11
-
12
- context "" do
13
- before(:each) do
14
- stub_request(
15
- :put,
16
- "https://example.cybozu.com/k/v1/field/acl.json"
17
- ).
18
- with(:body => {"id" => 1, "rights" => {"p1" => "abc", "p2" => "def"}}.to_json).
19
- to_return(:body => "{}", :status => 200)
20
- end
21
-
22
- let(:id) { 1 }
23
- let(:rights) { {"p1" => "abc", "p2" => "def"} }
24
-
25
- it { expect(subject).to eq({}) }
26
- end
27
- end
28
- end
@@ -1,25 +0,0 @@
1
- require 'kintone/command/form'
2
- require 'kintone/api'
3
-
4
- describe Kintone::Command::Form do
5
- let(:target) { Kintone::Command::Form.new(api) }
6
- let(:api) { Kintone::Api.new("example.cybozu.com", "Administrator", "cybozu") }
7
-
8
- describe "#get" do
9
- subject { target.get(app) }
10
-
11
- context "" do
12
- before(:each) do
13
- stub_request(
14
- :get,
15
- "https://example.cybozu.com/k/v1/form.json?app=4"
16
- ).
17
- to_return(:body => "{\"result\":\"ok\"}", :status => 200)
18
- end
19
-
20
- let(:app) { 4 }
21
-
22
- it { expect(subject).to eq({"result" => "ok"})}
23
- end
24
- end
25
- end
@@ -1,28 +0,0 @@
1
- require 'spec_helper'
2
- require 'kintone/command/record_acl'
3
- require 'kintone/api'
4
-
5
- describe Kintone::Command::RecordAcl do
6
- let(:target) { Kintone::Command::RecordAcl.new(api) }
7
- let(:api) { Kintone::Api.new("example.cybozu.com", "Administrator", "cybozu") }
8
-
9
- describe "#update" do
10
- subject { target.update(id, rights) }
11
-
12
- context "" do
13
- before(:each) do
14
- stub_request(
15
- :put,
16
- "https://example.cybozu.com/k/v1/record/acl.json"
17
- ).
18
- with(:body => {"id" => 1, "rights" => {"p1" => "abc", "p2" => "def"}}.to_json).
19
- to_return(:body => "{}", :status => 200)
20
- end
21
-
22
- let(:id) { 1 }
23
- let(:rights) { {"p1" => "abc", "p2" => "def"} }
24
-
25
- it { expect(subject).to eq({}) }
26
- end
27
- end
28
- end
@@ -1,92 +0,0 @@
1
- require 'spec_helper'
2
- require 'kintone/command/record'
3
- require 'kintone/api'
4
-
5
- describe Kintone::Command::Record do
6
- let(:target) { Kintone::Command::Record.new(api) }
7
- let(:api) { Kintone::Api.new("www.example.com", "Administrator", "cybozu") }
8
-
9
- describe "#get" do
10
- subject { target.get(app, id) }
11
-
12
- context "引数が整数型の時" do
13
- before(:each) do
14
- stub_request(
15
- :get,
16
- "https://www.example.com/k/v1/record.json?app=8&id=100"
17
- ).
18
- to_return(:body => "{\"result\":\"ok\"}", :status => 200)
19
- end
20
-
21
- let(:app) { 8 }
22
- let(:id) { 100 }
23
-
24
- it { expect(subject).to eq({"result" => "ok"}) }
25
- end
26
-
27
- context "引数が数字の文字列の時" do
28
- before(:each) do
29
- stub_request(
30
- :get,
31
- "https://www.example.com/k/v1/record.json?app=8&id=100"
32
- ).
33
- to_return(:body => "{\"result\":\"ok\"}", :status => 200)
34
- end
35
-
36
- let(:app) { "8" }
37
- let(:id) { "100" }
38
-
39
- it { expect(subject).to eq({"result" => "ok"}) }
40
- end
41
- end
42
-
43
- describe "#create" do
44
- def hash_record
45
- return {
46
- "number" => {"value" => "123456"},
47
- "rich_editor" => {"value" => "testtest"},
48
- "user_select" => {"value" => [{"code" => "sato"}]}
49
- }
50
- end
51
- before(:each) do
52
- stub_request(
53
- :post,
54
- "https://www.example.com/k/v1/record.json"
55
- ).
56
- with(:body => {"app" => 7, "record" => hash_record}.to_json).
57
- to_return(:body => "{\"id\":\"100\"}", :status => 200)
58
- end
59
-
60
- subject { target.create(app, record) }
61
-
62
- let(:app) { 7 }
63
- let(:record) { hash_record }
64
-
65
- it { expect(subject).to eq({"id" => "100"}) }
66
- end
67
-
68
- describe "#update" do
69
- def hash_record
70
- return {
71
- "string_multi" => {"value" => "character string is changed"}
72
- }
73
- end
74
-
75
- before(:each) do
76
- stub_request(
77
- :put,
78
- "https://www.example.com/k/v1/record.json"
79
- ).
80
- with(:body => {"app" => 4, "id" => 1, "record" => hash_record}.to_json).
81
- to_return(:body => "{}", :status => 200)
82
- end
83
-
84
- subject { target.update(app, id, record) }
85
-
86
- let(:app) { 4 }
87
- let(:id) { 1 }
88
- let(:record) { hash_record }
89
-
90
- it { expect(subject).to eq({}) }
91
- end
92
- end
@@ -1,162 +0,0 @@
1
- require 'spec_helper'
2
- require 'kintone/command/records'
3
- require 'kintone/api'
4
-
5
- describe Kintone::Command::Records do
6
- let(:target) { Kintone::Command::Records.new(api) }
7
- let(:api) { Kintone::Api.new("example.cybozu.com", "Administrator", "cybozu") }
8
-
9
- describe "#get" do
10
- subject { target.get(app, query, fields) }
11
- let(:app) { 8 }
12
- let(:query) { "" }
13
- let(:fields) { [] }
14
-
15
- context "アプリIDだけ指定した時" do
16
- before(:each) do
17
- stub_request(
18
- :get,
19
- "https://example.cybozu.com/k/v1/records.json?app=8&query="
20
- ).
21
- to_return(:body => "{\"records\":[{\"record_id\": {\"type\":\"RECORD_NUMBER\",\"value\":\"1\"}}]}", :status => 200)
22
- end
23
-
24
- it { expect(subject).to eq({"records" => [{"record_id" => {"type" => "RECORD_NUMBER", "value" => "1"}}]}) }
25
- end
26
-
27
- context "条件に文字列を含むqueryを指定した時" do
28
- before(:each) do
29
- stub_request(
30
- :get,
31
- "https://example.cybozu.com/k/v1/records.json?app=8&query=updated_time%20%3e%20%222012%2d02%2d03T09%3a00%3a00%2b0900%22%20and%20updated_time%20%3c%20%222012%2d02%2d03T10%3a00%3a00%2b0900%22"
32
- ).
33
- to_return(:body => "{\"records\":[{\"record_id\": {\"type\":\"RECORD_NUMBER\",\"value\":\"1\"}}]}", :status => 200)
34
- end
35
-
36
- let(:query) { "updated_time > \"2012-02-03T09:00:00+0900\" and updated_time < \"2012-02-03T10:00:00+0900\"" }
37
-
38
- it { expect(subject).to eq({"records" => [{"record_id" => {"type" => "RECORD_NUMBER", "value" => "1"}}]}) }
39
- end
40
-
41
- context "項目に全角文字を含むfieldsを指定した時" do
42
- before(:each) do
43
- stub_request(
44
- :get,
45
- "https://example.cybozu.com/k/v1/records.json?app=8&query=&fields%5b0%5d=%E3%83%AC%E3%82%B3%E3%83%BC%E3%83%89%E7%95%AA%E5%8F%B7&fields%5b1%5d=created_time&fields%5b2%5d=dropdown"
46
- ).
47
- to_return(:body => "{\"records\":[{\"record_id\": {\"type\":\"RECORD_NUMBER\",\"value\":\"1\"}}]}", :status => 200)
48
- end
49
-
50
- let(:fields) { ["レコード番号", "created_time", "dropdown"] }
51
-
52
- it { expect(subject).to eq({"records" => [{"record_id" => {"type" => "RECORD_NUMBER", "value" => "1"}}]}) }
53
- end
54
-
55
- context "queryにnilを指定した時" do
56
- before(:each) do
57
- stub_request(
58
- :get,
59
- "https://example.cybozu.com/k/v1/records.json?app=8&query"
60
- ).
61
- to_return(:body => "{\"records\":[{\"record_id\": {\"type\":\"RECORD_NUMBER\",\"value\":\"1\"}}]}", :status => 200)
62
- end
63
-
64
- let(:query) { nil }
65
-
66
- it { expect(subject).to eq({"records" => [{"record_id" => {"type" => "RECORD_NUMBER", "value" => "1"}}]}) }
67
- end
68
-
69
- context "fieldsにnilを指定した時" do
70
- let(:fields) { nil }
71
-
72
- it { expect{ subject }.to raise_error(NoMethodError)}
73
- end
74
- end
75
-
76
- describe "#create" do
77
- subject { target.create(app, records) }
78
-
79
- context "" do
80
- def records_data
81
- return [
82
- {
83
- "rich_editor" => {"value" => "testtest"}
84
- },
85
- {
86
- "user_select" => {"value" => [{"code"=> "suzuki"}]}
87
- }
88
- ]
89
- end
90
-
91
- before(:each) do
92
- stub_request(
93
- :post,
94
- "https://example.cybozu.com/k/v1/records.json"
95
- ).
96
- with(:body => {"app" => 7, "records" => records_data}.to_json).
97
- to_return(:body => "{\"ids\":[\"100\", \"101\"]}", :status => 200)
98
- end
99
-
100
- let(:app) { 7 }
101
- let(:records) { records_data }
102
-
103
- it { expect(subject).to eq({"ids" => ["100", "101"]}) }
104
- end
105
- end
106
-
107
- describe "#update" do
108
- subject { target.update(app, records) }
109
-
110
- context "" do
111
- def records_data
112
- return [
113
- {
114
- "id" => 1,
115
- "record" => {
116
- "string_1" => {"value" => "abcdef"}
117
- }
118
- },
119
- {
120
- "id" => 2,
121
- "record" => {
122
- "string_multi" => {"value" => "opqrstu"}
123
- }
124
- }
125
- ]
126
- end
127
-
128
- before(:each) do
129
- stub_request(
130
- :put,
131
- "https://example.cybozu.com/k/v1/records.json"
132
- ).
133
- with(:body => {"app" => 4, "records" => records_data}.to_json).
134
- to_return(:body => "{}", :status => 200)
135
- end
136
-
137
- let(:app) { 4 }
138
- let(:records) { records_data }
139
-
140
- it { expect(subject).to eq({}) }
141
- end
142
- end
143
-
144
- describe "#delete" do
145
- subject { target.delete(app, ids) }
146
-
147
- context "" do
148
- before(:each) do
149
- stub_request(
150
- :delete,
151
- "https://example.cybozu.com/k/v1/records.json?app=1&ids[0]=100&ids[1]=80"
152
- ).
153
- to_return(:body => "{}", :status => 200)
154
- end
155
-
156
- let(:app) { 1 }
157
- let(:ids) { [100, 80] }
158
-
159
- it { expect(subject).to eq({}) }
160
- end
161
- end
162
- end