decidim-dev 0.29.0.rc2 → 0.29.0.rc4

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
  SHA256:
3
- metadata.gz: 5deceead79e05f6380eebf8b270d41f49a125a25489fd2e446d3d1e401b45906
4
- data.tar.gz: cf336e40f132e075e42c24bb8625ba8210a3c40c77a519431600a3d6a5fe7260
3
+ metadata.gz: 01ebcb8bacb02ac7084ba989750b0086a8ff10b7b74e8d181e80667f37493b01
4
+ data.tar.gz: 8e0f4c14e5a1dc095118d3e2a4cbd2114b00ed6fd12686161efe3e45753fdaab
5
5
  SHA512:
6
- metadata.gz: 8155273a5941c76c6c245f826b61b1351a7bf2126e8c81c02c4a51db0b8cdf503d88c78a1b5fe165ea86dc0efa91e629559d2afd8f7c0dbb5cc38c72edc965a9
7
- data.tar.gz: 877eef5aea010b368822af603a7c636da688affff6dcbb0ad100dbeb8f4d751815c445dd43478ee0a14b4fb2ea3c7f1d1b5489745edcca0e14a9e8b030dfd908
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
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "parallel_tests"
3
4
  require "selenium-webdriver"
4
5
 
5
6
  module Decidim
@@ -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.rc2"
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.rc2
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-16 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.rc2
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.rc2
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