decidim-dev 0.29.0.rc3 → 0.29.0.rc4

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
  SHA256:
3
- metadata.gz: 532ac1a2c87f914b38cd0ac1fc0a7803307f4008ab6aaa6b6dde29b33512f317
4
- data.tar.gz: 888f18d168c316b6fe7e1395f71b5cbbf5bbd162caa36941af3a01e7fca9c63c
3
+ metadata.gz: 01ebcb8bacb02ac7084ba989750b0086a8ff10b7b74e8d181e80667f37493b01
4
+ data.tar.gz: 8e0f4c14e5a1dc095118d3e2a4cbd2114b00ed6fd12686161efe3e45753fdaab
5
5
  SHA512:
6
- metadata.gz: 62a83d2bc9cb90abfcf4e5c153af5d91805c6ffdada4d0b47b1387945c50156fb6c9095fa5fce4c620a86743f09ffd7fa477f26b8c2fff6a9b930dfb5bc77747
7
- data.tar.gz: 7bbcc991b9a80332e430e187031761c3dcd41e856406825c24edfeba67046ad2d58d2505ebf760a0305c63d573012bbe310020039a771ff54403961cc3eb61e3
6
+ metadata.gz: c93d472a29c6af4fa2e4734ebe1f5517aba9ea0e709afe511f7bc84974e7531e44280b34e995a042edcb7de6d7493109c9d4ad94ce5e3cdbcfd15cdc70247658
7
+ data.tar.gz: f0392dd9630a7200b04f1e735613ea71eba1a344f52584e867b60e737c56846e5f19512b8dea3eef050eb68dae49400bf8253e9a5235834ef54fdb304d75fb63
@@ -0,0 +1,148 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveStorageMatchers
4
+ def be_blob_url(expected)
5
+ BeBlobUrl.new(expected)
6
+ end
7
+
8
+ def include_blob_urls(*expected)
9
+ IncludeBlobUrls.new(expected)
10
+ end
11
+
12
+ class BlobMatch
13
+ BLOB_URL_MATCHERS = {
14
+ redirect: %r{/rails/active_storage/blobs/redirect/([^/]+)/([^/]+)$},
15
+ representation: %r{/rails/active_storage/representations/redirect/([^/]+)/([^/]+)/([^/]+)$},
16
+ disk: %r{/rails/active_storage/disk/([^/]+)/([^/]+)$}
17
+ }.freeze
18
+
19
+ def initialize(url)
20
+ @url = url
21
+ end
22
+
23
+ def blob
24
+ return unless key_match
25
+
26
+ @blob ||=
27
+ case url_type
28
+ when :redirect, :representation
29
+ ActiveStorage::Blob.find_signed(key_match)
30
+ when :disk
31
+ decoded = ActiveStorage.verifier.verified(key_match, purpose: :blob_key)
32
+ ActiveStorage::Blob.find_by(key: decoded[:key]) if decoded
33
+ end
34
+ end
35
+
36
+ def variation
37
+ return unless variation_match
38
+
39
+ blob.representation(variation_match)
40
+ end
41
+
42
+ def key_match
43
+ return unless match
44
+
45
+ match[1]
46
+ end
47
+
48
+ def variation_match
49
+ return unless match
50
+
51
+ match[2] if url_type == :representation
52
+ end
53
+
54
+ def filename_match
55
+ return unless match
56
+
57
+ case url_type
58
+ when :representation
59
+ match[3]
60
+ else
61
+ match[2]
62
+ end
63
+ end
64
+
65
+ private
66
+
67
+ attr_reader :url, :url_type
68
+
69
+ def match
70
+ return @match if @url_type
71
+
72
+ @url_type = :none
73
+ @match = nil
74
+ BLOB_URL_MATCHERS.each do |type, matcher|
75
+ @match = url.match(matcher)
76
+ if @match
77
+ @url_type = type
78
+ break
79
+ end
80
+ end
81
+
82
+ @match
83
+ end
84
+ end
85
+
86
+ class BeBlobUrl
87
+ def initialize(expected)
88
+ @expected = expected
89
+ end
90
+
91
+ def description
92
+ "be a blob URL"
93
+ end
94
+
95
+ def matches?(actual)
96
+ @actual = actual
97
+ match = BlobMatch.new(actual)
98
+ match.blob == expected
99
+ end
100
+
101
+ def failure_message
102
+ "expected #{actual} to match blob with ID #{expected.id}"
103
+ end
104
+
105
+ def failure_message_when_negated
106
+ "expected #{actual} not to match blob with ID #{expected.id}"
107
+ end
108
+
109
+ private
110
+
111
+ attr_reader :expected, :actual
112
+ end
113
+
114
+ class IncludeBlobUrls
115
+ def initialize(expected)
116
+ @expected = expected
117
+ end
118
+
119
+ def description
120
+ "include blob URLs"
121
+ end
122
+
123
+ def matches?(actual)
124
+ @actual = actual
125
+
126
+ actual.all? do |url|
127
+ match = BlobMatch.new(url)
128
+ expected.include?(match.blob)
129
+ end
130
+ end
131
+
132
+ def failure_message
133
+ "expected #{actual.inspect} to match blobs with ID #{expected.map(&:id).join(", ")}"
134
+ end
135
+
136
+ def failure_message_when_negated
137
+ "expected #{actual.inspect} not to match blobs with ID #{expected.map(&:id).join(", ")}"
138
+ end
139
+
140
+ private
141
+
142
+ attr_reader :expected, :actual
143
+ end
144
+ end
145
+
146
+ RSpec.configure do |config|
147
+ config.include ActiveStorageMatchers
148
+ end
@@ -45,4 +45,11 @@ RSpec.configure do |config|
45
45
  "connect-src": %W(#{Decidim::Dev::Test::MapServer.host})
46
46
  }
47
47
  end
48
+
49
+ config.before do
50
+ # Ensure that the current host is not set for any spec in order to test that
51
+ # the automatic current host definition is working correctly in all
52
+ # situations.
53
+ ActiveStorage::Current.url_options = {}
54
+ end
48
55
  end
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-dev version.
5
5
  module Dev
6
6
  def self.version
7
- "0.29.0.rc3"
7
+ "0.29.0.rc4"
8
8
  end
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-dev
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.29.0.rc3
4
+ version: 0.29.0.rc4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep Jaume Rey Peroy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-07-22 00:00:00.000000000 Z
13
+ date: 2024-07-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: capybara
@@ -32,14 +32,14 @@ dependencies:
32
32
  requirements:
33
33
  - - '='
34
34
  - !ruby/object:Gem::Version
35
- version: 0.29.0.rc3
35
+ version: 0.29.0.rc4
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - '='
41
41
  - !ruby/object:Gem::Version
42
- version: 0.29.0.rc3
42
+ version: 0.29.0.rc4
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: factory_bot_rails
45
45
  requirement: !ruby/object:Gem::Requirement
@@ -681,6 +681,7 @@ files:
681
681
  - lib/decidim/dev/test/rspec_support/accessibility_examples.rb
682
682
  - lib/decidim/dev/test/rspec_support/action_mailer.rb
683
683
  - lib/decidim/dev/test/rspec_support/active_job.rb
684
+ - lib/decidim/dev/test/rspec_support/activestorage_matchers.rb
684
685
  - lib/decidim/dev/test/rspec_support/attachment_helpers.rb
685
686
  - lib/decidim/dev/test/rspec_support/authorization.rb
686
687
  - lib/decidim/dev/test/rspec_support/autocomplete_select.rb