tessa 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7330e2363eb33ab7cf7d633ff85959ebf4b45587
4
- data.tar.gz: 6ab6b9a99baa857d4309a6261fcb4f912cb0ea07
3
+ metadata.gz: 28f2e67e5941ce5ab317926e7bdf19e485fb185c
4
+ data.tar.gz: f1ef610302d7f4ab169b2c74fb2221a2e072ca37
5
5
  SHA512:
6
- metadata.gz: 0c61f52d569422acf00b552d0bb949181673fcab38e74392a564e19380749f81a366e90d39c0586fe0e2e08d96911be5fa4456d87faaf5cfb6fe5a881f604138
7
- data.tar.gz: 340143a079e8626cfac95e2f4841faa2b8333741656933da0dd0b24963b814861d25866badb136da1969695d90a5540b177f775029e06ace7139f94aa3436bea
6
+ metadata.gz: d0361b4bf36f9e308a402c77ad9c1d47aa600037b74b1d5cc0db8734b19d299f2e0ce262fbb085050f788d5cea565742af30f8fa12511b1534bfc7563f7dc553
7
+ data.tar.gz: 55a1356667f4a7b10d4ac592af9a5218c832e3a943c6935b0110393cd414ad99d0fee721c8236e5bd4e6d8718903b21ea2377090750fbc87e2ee9d14ead3ad3a
@@ -0,0 +1 @@
1
+ 2.3.3
@@ -1,9 +1,17 @@
1
+ env:
2
+ global:
3
+ - CC_TEST_REPORTER_ID=a1d1020f21ac7490fa6c577e7718c505a0bc7f13a5e4537ec7ca9f1a594bad07
1
4
  before_install: gem update bundler
2
5
  language: ruby
3
6
  notifications:
4
7
  email: false
5
8
  rvm:
6
- - 2.1.0
7
- addons:
8
- code_climate:
9
- repo_token: a1d1020f21ac7490fa6c577e7718c505a0bc7f13a5e4537ec7ca9f1a594bad07
9
+ - 2.3.3
10
+ before_script:
11
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
12
+ - chmod +x ./cc-test-reporter
13
+ - ./cc-test-reporter before-build
14
+ script:
15
+ - bundle exec rspec
16
+ after_script:
17
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/README.md CHANGED
@@ -40,7 +40,7 @@ TODO: Write usage instructions here
40
40
  [2]: http://rubygems.org/gems/tessa "Gem Version"
41
41
  [3]: https://img.shields.io/travis/watermarkchurch/tessa-client/master.svg?style=flat
42
42
  [4]: https://travis-ci.org/watermarkchurch/tessa-client "Build Status"
43
- [5]: https://codeclimate.com/github/watermarkchurch/tessa-client/badges/coverage.svg
44
- [6]: https://codeclimate.com/github/watermarkchurch/tessa-client "Coverage Status"
45
- [7]: https://img.shields.io/codeclimate/github/watermarkchurch/tessa-client.svg?style=flat
46
- [8]: https://codeclimate.com/github/watermarkchurch/tessa-client "Code Climate"
43
+ [5]: https://api.codeclimate.com/v1/badges/14600955bbe143bee625/test_coverage
44
+ [6]: https://codeclimate.com/github/watermarkchurch/tessa-client/test_coverage "Coverage Status"
45
+ [7]: https://api.codeclimate.com/v1/badges/14600955bbe143bee625/maintainability
46
+ [8]: https://codeclimate.com/github/watermarkchurch/tessa-client/maintainability "Code Climate"
data/circle.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  machine:
2
2
  ruby:
3
- version: 2.2.0
3
+ version: 2.3.3
@@ -48,10 +48,17 @@ module Tessa
48
48
  end
49
49
  end
50
50
 
51
+ private def reapplying_asset?(field, change_set)
52
+ additions = change_set.changes.select(&:add?)
53
+
54
+ return false if additions.none?
55
+ return false if change_set.changes.size > additions.size
56
+
57
+ additions.all? { |a| field.ids(on: self).include?(a.id) }
58
+ end
51
59
  end
52
60
 
53
61
  module ClassMethods
54
-
55
62
  def asset(name, args={})
56
63
  field = tessa_fields[name] = Field.new(args.merge(name: name))
57
64
 
@@ -71,6 +78,9 @@ module Tessa
71
78
  dynamic_extensions.send(:define_method, "#{name}=") do |value|
72
79
  change_set = field.change_set_for(value)
73
80
 
81
+ # should effectively cause a no-op
82
+ return if reapplying_asset?(field, change_set)
83
+
74
84
  if !(field.multiple? && value.is_a?(AssetChangeSet))
75
85
  new_ids = change_set.scoped_changes.select(&:add?).map(&:id)
76
86
  change_set += field.difference_change_set(new_ids, on: self)
@@ -91,8 +101,6 @@ module Tessa
91
101
  def inherited(subclass)
92
102
  subclass.instance_variable_set(:@tessa_fields, @tessa_fields.dup)
93
103
  end
94
-
95
104
  end
96
-
97
105
  end
98
106
  end
@@ -1,3 +1,3 @@
1
1
  module Tessa
2
- VERSION = "0.9.1"
2
+ VERSION = "0.9.2"
3
3
  end
@@ -1,9 +1,15 @@
1
1
  require 'tessa'
2
+ require 'tempfile'
2
3
 
3
4
  Dir[File.expand_path("../support/*.rb", __FILE__)].each do |file|
4
5
  require file
5
6
  end
6
7
 
8
+ if ENV['SIMPLE_COV'] || ENV['CC_TEST_REPORTER_ID']
9
+ require 'simplecov'
10
+ SimpleCov.start
11
+ end
12
+
7
13
  RSpec.configure do |config|
8
14
  config.expect_with :rspec do |expectations|
9
15
  expectations.include_chain_clauses_in_custom_matcher_descriptions = true
@@ -241,6 +241,24 @@ RSpec.describe Tessa::Model do
241
241
  expect(new_set.scoped_ids).to eq(set.scoped_ids)
242
242
  end
243
243
 
244
+ it 'keeps asset when set to existing value' do
245
+ change_set = Tessa::AssetChangeSet.new(
246
+ changes: { '999' => { 'action' => 'add' } },
247
+ scoped_ids: [999]
248
+ )
249
+ instance.file = change_set
250
+ expect(instance.file_id).to eq(999)
251
+
252
+ change_set.scoped_ids = [4, 5, 6]
253
+ instance.file = change_set
254
+ removals = change_set.changes.select(&:remove?).map(&:id)
255
+ expect(removals).to_not include(999)
256
+ expect(instance.file_id).to eq(999)
257
+
258
+ instance.file = change_set
259
+ expect(instance.file_id).to eq(999)
260
+ end
261
+
244
262
  context "with no remove in change set" do
245
263
  it "ensures there is a 'remove' action for previous value" do
246
264
  instance.file_id = 2
@@ -43,9 +43,11 @@ RSpec.describe Tessa::Upload::UploadsFile do
43
43
  }
44
44
 
45
45
  it "calls the upload_url with upload_method HTTP method" do
46
- file = __FILE__
47
- expect(connection).to receive(:post).with("http://upload/path?arg=1", hash_including(:file)).and_call_original
48
- expect(task.call(file)).to be_truthy
46
+ file = Tempfile.new("test")
47
+ file.write "hello there"
48
+ file.close
49
+ expect(connection).to receive(:post).with("http://upload/path?arg=1", "hello there").and_call_original
50
+ expect(task.call(file.path)).to be_truthy
49
51
  end
50
52
  end
51
53
 
@@ -59,19 +61,21 @@ RSpec.describe Tessa::Upload::UploadsFile do
59
61
  }
60
62
 
61
63
  it "calls the upload_url with upload_method HTTP method" do
62
- file = __FILE__
63
- expect(connection).to receive(:post).with("http://upload/path?arg=1", hash_including(:file)).and_call_original
64
- expect(task.call(file)).to be_falsey
64
+ file = Tempfile.new("test")
65
+ file.write "hello there"
66
+ file.close
67
+ expect(connection).to receive(:post).with("http://upload/path?arg=1", "hello there").and_call_original
68
+ expect(task.call(file.path)).to be_falsey
65
69
  end
66
70
  end
67
71
  end
68
72
 
69
73
  describe ".connection_factory" do
70
- it "returns a new Faraday::Connection with the default adapter and url_encoded and multipart" do
74
+ it "returns a new Faraday::Connection with the default adapter" do
71
75
  obj = described_class.connection_factory
72
76
  expect(obj).to be_a(Faraday::Connection)
73
77
  expect(obj.builder.handlers)
74
- .to eq([Faraday::Request::Multipart, Faraday::Request::UrlEncoded, Faraday::Adapter::NetHttp])
78
+ .to eq([Faraday::Adapter::NetHttp])
75
79
  end
76
80
  end
77
81
 
@@ -13,6 +13,8 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = "https://github.com/watermarkchurch/tessa-client"
14
14
  spec.license = "MIT"
15
15
 
16
+ spec.required_ruby_version = '~> 2.3'
17
+
16
18
  spec.files = `git ls-files -z`.split("\x0")
17
19
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
@@ -24,4 +26,5 @@ Gem::Specification.new do |spec|
24
26
  spec.add_development_dependency "bundler", "~> 1.7"
25
27
  spec.add_development_dependency "rake", "~> 10.0"
26
28
  spec.add_development_dependency "rspec", "~> 3.1"
29
+ spec.add_development_dependency "simplecov", "~> 0.15.1"
27
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tessa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Powell
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-02-23 00:00:00.000000000 Z
12
+ date: 2018-01-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -81,6 +81,20 @@ dependencies:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
83
  version: '3.1'
84
+ - !ruby/object:Gem::Dependency
85
+ name: simplecov
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: 0.15.1
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: 0.15.1
84
98
  description: Manage your assets.
85
99
  email:
86
100
  - jpowell@watermark.org
@@ -93,6 +107,7 @@ files:
93
107
  - ".env.example"
94
108
  - ".gitignore"
95
109
  - ".rspec"
110
+ - ".ruby-version"
96
111
  - ".travis.yml"
97
112
  - Gemfile
98
113
  - LICENSE.txt
@@ -139,9 +154,9 @@ require_paths:
139
154
  - lib
140
155
  required_ruby_version: !ruby/object:Gem::Requirement
141
156
  requirements:
142
- - - ">="
157
+ - - "~>"
143
158
  - !ruby/object:Gem::Version
144
- version: '0'
159
+ version: '2.3'
145
160
  required_rubygems_version: !ruby/object:Gem::Requirement
146
161
  requirements:
147
162
  - - ">="
@@ -149,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
164
  version: '0'
150
165
  requirements: []
151
166
  rubyforge_project:
152
- rubygems_version: 2.6.8
167
+ rubygems_version: 2.6.11
153
168
  signing_key:
154
169
  specification_version: 4
155
170
  summary: Manage your assets.