Class: ActiveStorageMatchers::BlobMatch
- Inherits:
 - 
      Object
      
        
- Object
 - ActiveStorageMatchers::BlobMatch
 
 
- Defined in:
 - lib/decidim/dev/test/rspec_support/activestorage_matchers.rb
 
Constant Summary collapse
- BLOB_URL_MATCHERS =
 { redirect: %r{/rails/active_storage/blobs/redirect/([^/]+)/([^/]+)$}, representation: %r{/rails/active_storage/representations/redirect/([^/]+)/([^/]+)/([^/]+)$}, disk: %r{/rails/active_storage/disk/([^/]+)/([^/]+)$} }.freeze
Instance Method Summary collapse
- #blob ⇒ Object
 - #filename_match ⇒ Object
 - 
  
    
      #initialize(url)  ⇒ BlobMatch 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of BlobMatch.
 - #key_match ⇒ Object
 - #variation ⇒ Object
 - #variation_match ⇒ Object
 
Constructor Details
#initialize(url) ⇒ BlobMatch
Returns a new instance of BlobMatch.
      19 20 21  | 
    
      # File 'lib/decidim/dev/test/rspec_support/activestorage_matchers.rb', line 19 def initialize(url) @url = url end  | 
  
Instance Method Details
#blob ⇒ Object
      23 24 25 26 27 28 29 30 31 32 33 34  | 
    
      # File 'lib/decidim/dev/test/rspec_support/activestorage_matchers.rb', line 23 def blob return unless key_match @blob ||= case url_type when :redirect, :representation ActiveStorage::Blob.find_signed(key_match) when :disk decoded = ActiveStorage.verifier.verified(key_match, purpose: :blob_key) ActiveStorage::Blob.find_by(key: decoded[:key]) if decoded end end  | 
  
#filename_match ⇒ Object
      54 55 56 57 58 59 60 61 62 63  | 
    
      # File 'lib/decidim/dev/test/rspec_support/activestorage_matchers.rb', line 54 def filename_match return unless match case url_type when :representation match[3] else match[2] end end  | 
  
#key_match ⇒ Object
      42 43 44 45 46  | 
    
      # File 'lib/decidim/dev/test/rspec_support/activestorage_matchers.rb', line 42 def key_match return unless match match[1] end  | 
  
#variation ⇒ Object
      36 37 38 39 40  | 
    
      # File 'lib/decidim/dev/test/rspec_support/activestorage_matchers.rb', line 36 def variation return unless variation_match blob.representation(variation_match) end  | 
  
#variation_match ⇒ Object
      48 49 50 51 52  | 
    
      # File 'lib/decidim/dev/test/rspec_support/activestorage_matchers.rb', line 48 def variation_match return unless match match[2] if url_type == :representation end  |