contentstack 0.6.3.1 → 0.7.0
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 +4 -4
 - data/.github/workflows/check-branch.yml +20 -0
 - data/.github/workflows/codeql-analysis.yml +68 -68
 - data/.github/workflows/jira.yml +28 -28
 - data/.github/workflows/release-gem.yml +30 -30
 - data/.github/workflows/sast-scan.yml +10 -10
 - data/.github/workflows/sca-scan.yml +15 -15
 - data/.github/workflows/secrets-scan.yml +10 -10
 - data/.gitignore +11 -11
 - data/.yardopts +6 -6
 - data/CHANGELOG.md +129 -114
 - data/CODEOWNERS +1 -1
 - data/CODE_OF_CONDUCT.md +73 -73
 - data/Gemfile +2 -2
 - data/Gemfile.lock +79 -76
 - data/LICENSE.txt +21 -21
 - data/README.md +197 -197
 - data/SECURITY.md +27 -27
 - data/contentstack.gemspec +29 -29
 - data/lib/contentstack/api.rb +191 -191
 - data/lib/contentstack/asset.rb +68 -68
 - data/lib/contentstack/asset_collection.rb +27 -27
 - data/lib/contentstack/client.rb +122 -91
 - data/lib/contentstack/content_type.rb +53 -53
 - data/lib/contentstack/entry.rb +235 -221
 - data/lib/contentstack/entry_collection.rb +44 -44
 - data/lib/contentstack/error.rb +6 -6
 - data/lib/contentstack/query.rb +665 -653
 - data/lib/contentstack/region.rb +13 -5
 - data/lib/contentstack/sync_result.rb +29 -29
 - data/lib/contentstack/version.rb +2 -2
 - data/lib/contentstack.rb +31 -31
 - data/lib/util.rb +110 -110
 - data/rakefile.rb +3 -3
 - data/spec/asset_collection_spec.rb +15 -15
 - data/spec/asset_spec.rb +47 -47
 - data/spec/content_type_spec.rb +80 -80
 - data/spec/contentstack_spec.rb +63 -38
 - data/spec/entry_collection_spec.rb +41 -41
 - data/spec/entry_spec.rb +116 -101
 - data/spec/fixtures/asset.json +1 -1
 - data/spec/fixtures/asset_collection.json +1 -1
 - data/spec/fixtures/category_content_type.json +1 -1
 - data/spec/fixtures/category_entry.json +1 -1
 - data/spec/fixtures/category_entry_collection.json +1 -1
 - data/spec/fixtures/category_entry_collection_without_count.json +1 -1
 - data/spec/fixtures/content_types.json +1 -1
 - data/spec/fixtures/product_entry.json +1 -1
 - data/spec/fixtures/product_entry_collection.json +1 -1
 - data/spec/fixtures/sync_init.json +2974 -2974
 - data/spec/query_spec.rb +210 -205
 - data/spec/spec_helper.rb +180 -180
 - data/spec/sync_spec.rb +26 -26
 - metadata +4 -3
 
    
        data/spec/query_spec.rb
    CHANGED
    
    | 
         @@ -1,206 +1,211 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'spec_helper'
         
     | 
| 
       2 
     | 
    
         
            -
            require_relative '../lib/contentstack.rb'
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            describe Contentstack::Query do
         
     | 
| 
       5 
     | 
    
         
            -
              let(:client) { create_client }
         
     | 
| 
       6 
     | 
    
         
            -
              let(:preview_client) { create_preview_client }
         
     | 
| 
       7 
     | 
    
         
            -
              let(:category_query) {client.content_type("category").query}
         
     | 
| 
       8 
     | 
    
         
            -
              let(:preview_category) {preview_client.content_type("category").query}
         
     | 
| 
       9 
     | 
    
         
            -
              let(:product_query) {client.content_type("product").query}
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
              it "should get data using `where` method" do
         
     | 
| 
       12 
     | 
    
         
            -
                data = category_query.where({title: "Electronics"}).fetch
         
     | 
| 
       13 
     | 
    
         
            -
                expect(data.length).to eq 5
         
     | 
| 
       14 
     | 
    
         
            -
              end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
              it "should get data using `regex` method" do
         
     | 
| 
       17 
     | 
    
         
            -
                data = category_query.regex("title", "App.*").fetch
         
     | 
| 
       18 
     | 
    
         
            -
                expect(data.length).to eq 5
         
     | 
| 
       19 
     | 
    
         
            -
              end
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
              it "is preview entry featch" do
         
     | 
| 
       22 
     | 
    
         
            -
                preview_client.live_preview_query({hash: 'hash', content_type_uid: 'category'})
         
     | 
| 
       23 
     | 
    
         
            -
                data = preview_category.fetch
         
     | 
| 
       24 
     | 
    
         
            -
                expect(data.length).to eq 5
         
     | 
| 
       25 
     | 
    
         
            -
              end
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
              it "should get data using `less_than` method" do
         
     | 
| 
       28 
     | 
    
         
            -
                data = product_query.less_than("price", 150).fetch
         
     | 
| 
       29 
     | 
    
         
            -
                expect(data.length).to eq 3
         
     | 
| 
       30 
     | 
    
         
            -
              end
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
              it "should get data using `less_than_or_equal` method" do
         
     | 
| 
       33 
     | 
    
         
            -
                data = product_query.less_than_or_equal("price", 166).fetch
         
     | 
| 
       34 
     | 
    
         
            -
                expect(data.length).to eq 3
         
     | 
| 
       35 
     | 
    
         
            -
              end
         
     | 
| 
       36 
     | 
    
         
            -
              
         
     | 
| 
       37 
     | 
    
         
            -
              it "should get data using `greater_than` method" do
         
     | 
| 
       38 
     | 
    
         
            -
                data = product_query.greater_than("price", 120).fetch
         
     | 
| 
       39 
     | 
    
         
            -
                expect(data.length).to eq 3
         
     | 
| 
       40 
     | 
    
         
            -
              end
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
              it "should get data using `greater_than_or_equal` method" do
         
     | 
| 
       43 
     | 
    
         
            -
                data = product_query.greater_than_or_equal("price", 166).fetch
         
     | 
| 
       44 
     | 
    
         
            -
                expect(data.length).to eq 3
         
     | 
| 
       45 
     | 
    
         
            -
              end
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
              it "should get data using `not_equal_to` method" do
         
     | 
| 
       48 
     | 
    
         
            -
                data = product_query.not_equal_to("price", 166).fetch
         
     | 
| 
       49 
     | 
    
         
            -
                expect(data.length).to eq 3
         
     | 
| 
       50 
     | 
    
         
            -
              end
         
     | 
| 
       51 
     | 
    
         
            -
              
         
     | 
| 
       52 
     | 
    
         
            -
              it "should get data using `limit` method" do
         
     | 
| 
       53 
     | 
    
         
            -
                data = category_query.limit(2).fetch
         
     | 
| 
       54 
     | 
    
         
            -
                expect(data.length).to eq 5
         
     | 
| 
       55 
     | 
    
         
            -
              end
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
              it "should get data using `skip` method" do
         
     | 
| 
       58 
     | 
    
         
            -
                data = category_query.skip(5).fetch
         
     | 
| 
       59 
     | 
    
         
            -
                expect(data.length).to eq 5
         
     | 
| 
       60 
     | 
    
         
            -
              end
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
              it "should get data using `include_count` method" do
         
     | 
| 
       63 
     | 
    
         
            -
                data = category_query.include_count.fetch
         
     | 
| 
       64 
     | 
    
         
            -
                expect(data.count).not_to be nil
         
     | 
| 
       65 
     | 
    
         
            -
                expect(data.count).to eq 5
         
     | 
| 
       66 
     | 
    
         
            -
              end
         
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
              it "should get data using ` 
     | 
| 
       69 
     | 
    
         
            -
                data = category_query. 
     | 
| 
       70 
     | 
    
         
            -
                expect(data. 
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
                data 
     | 
| 
       76 
     | 
    
         
            -
                expect(data.first.fields[: 
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
                data 
     | 
| 
       82 
     | 
    
         
            -
                expect(data.first.fields[: 
     | 
| 
       83 
     | 
    
         
            -
              end
         
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
              it "should get data using `except` method with  
     | 
| 
       86 
     | 
    
         
            -
                data = category_query.except( 
     | 
| 
       87 
     | 
    
         
            -
                expect(data.first.fields[: 
     | 
| 
       88 
     | 
    
         
            -
              end
         
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
     | 
    
         
            -
              it "should get data using ` 
     | 
| 
       91 
     | 
    
         
            -
                data = category_query. 
     | 
| 
       92 
     | 
    
         
            -
                expect(data. 
     | 
| 
       93 
     | 
    
         
            -
              end
         
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
              it "should get data using ` 
     | 
| 
       96 
     | 
    
         
            -
                data = category_query. 
     | 
| 
       97 
     | 
    
         
            -
                expect(data.length).to eq 5
         
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
       100 
     | 
    
         
            -
               
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
                data 
     | 
| 
       104 
     | 
    
         
            -
                expect(data. 
     | 
| 
       105 
     | 
    
         
            -
              end
         
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
              it "should get data using ` 
     | 
| 
       108 
     | 
    
         
            -
                data = category_query. 
     | 
| 
       109 
     | 
    
         
            -
                expect(data.length).to eq 5
         
     | 
| 
       110 
     | 
    
         
            -
              end
         
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
              it "should get data using ` 
     | 
| 
       113 
     | 
    
         
            -
                data = category_query. 
     | 
| 
       114 
     | 
    
         
            -
                expect(data.length).to eq 5
         
     | 
| 
       115 
     | 
    
         
            -
              end
         
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
       117 
     | 
    
         
            -
              it "should get data using ` 
     | 
| 
       118 
     | 
    
         
            -
                data =  
     | 
| 
       119 
     | 
    
         
            -
                expect(data. 
     | 
| 
       120 
     | 
    
         
            -
              end
         
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
              it "should get data using ` 
     | 
| 
       123 
     | 
    
         
            -
                data = product_query. 
     | 
| 
       124 
     | 
    
         
            -
                expect(data.first.fields[:title]).to eq "Motorola Moto X4"
         
     | 
| 
       125 
     | 
    
         
            -
              end
         
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
              it "should get data using ` 
     | 
| 
       128 
     | 
    
         
            -
                data = product_query. 
     | 
| 
       129 
     | 
    
         
            -
                expect(data.first.fields[: 
     | 
| 
       130 
     | 
    
         
            -
              end
         
     | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
       132 
     | 
    
         
            -
              it "should get data using ` 
     | 
| 
       133 
     | 
    
         
            -
                data = product_query.include_reference('categories'). 
     | 
| 
       134 
     | 
    
         
            -
                expect(data.first.fields[:categories][0][:title]).to eq  
     | 
| 
       135 
     | 
    
         
            -
              end
         
     | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
       137 
     | 
    
         
            -
              it "should get data using ` 
     | 
| 
       138 
     | 
    
         
            -
                data =  
     | 
| 
       139 
     | 
    
         
            -
                expect(data. 
     | 
| 
       140 
     | 
    
         
            -
              end
         
     | 
| 
       141 
     | 
    
         
            -
             
     | 
| 
       142 
     | 
    
         
            -
              it "should get data using ` 
     | 
| 
       143 
     | 
    
         
            -
                data = category_query. 
     | 
| 
       144 
     | 
    
         
            -
                expect(data. 
     | 
| 
       145 
     | 
    
         
            -
              end
         
     | 
| 
       146 
     | 
    
         
            -
             
     | 
| 
       147 
     | 
    
         
            -
              it "should get data using ` 
     | 
| 
       148 
     | 
    
         
            -
                data =  
     | 
| 
       149 
     | 
    
         
            -
                 
     | 
| 
       150 
     | 
    
         
            -
             
     | 
| 
       151 
     | 
    
         
            -
               
     | 
| 
       152 
     | 
    
         
            -
              
         
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
                data 
     | 
| 
       155 
     | 
    
         
            -
                expect(data.first.fields[: 
     | 
| 
       156 
     | 
    
         
            -
              end
         
     | 
| 
       157 
     | 
    
         
            -
              
         
     | 
| 
       158 
     | 
    
         
            -
              it "should get data using `include_owner` method" do
         
     | 
| 
       159 
     | 
    
         
            -
                data = product_query. 
     | 
| 
       160 
     | 
    
         
            -
                expect(data.first.fields[: 
     | 
| 
       161 
     | 
    
         
            -
              end
         
     | 
| 
       162 
     | 
    
         
            -
             
     | 
| 
       163 
     | 
    
         
            -
              it "should get data using ` 
     | 
| 
       164 
     | 
    
         
            -
                data =  
     | 
| 
       165 
     | 
    
         
            -
                expect(data. 
     | 
| 
       166 
     | 
    
         
            -
              end
         
     | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
       168 
     | 
    
         
            -
              it "should get data using ` 
     | 
| 
       169 
     | 
    
         
            -
                data = category_query. 
     | 
| 
       170 
     | 
    
         
            -
                expect(data.length).to eq 5
         
     | 
| 
       171 
     | 
    
         
            -
              end
         
     | 
| 
       172 
     | 
    
         
            -
             
     | 
| 
       173 
     | 
    
         
            -
              it "should get data using ` 
     | 
| 
       174 
     | 
    
         
            -
                data = category_query. 
     | 
| 
       175 
     | 
    
         
            -
                expect(data).to eq 5
         
     | 
| 
       176 
     | 
    
         
            -
              end
         
     | 
| 
       177 
     | 
    
         
            -
             
     | 
| 
       178 
     | 
    
         
            -
              it "should get data using ` 
     | 
| 
       179 
     | 
    
         
            -
                data = category_query. 
     | 
| 
       180 
     | 
    
         
            -
                expect(data 
     | 
| 
       181 
     | 
    
         
            -
              end
         
     | 
| 
       182 
     | 
    
         
            -
             
     | 
| 
       183 
     | 
    
         
            -
              it "should get data using ` 
     | 
| 
       184 
     | 
    
         
            -
                data =  
     | 
| 
       185 
     | 
    
         
            -
                expect(data.length).to eq  
     | 
| 
       186 
     | 
    
         
            -
              end
         
     | 
| 
       187 
     | 
    
         
            -
             
     | 
| 
       188 
     | 
    
         
            -
              it "should get data using ` 
     | 
| 
       189 
     | 
    
         
            -
                 
     | 
| 
       190 
     | 
    
         
            -
                 
     | 
| 
       191 
     | 
    
         
            -
             
     | 
| 
       192 
     | 
    
         
            -
             
     | 
| 
       193 
     | 
    
         
            -
               
     | 
| 
       194 
     | 
    
         
            -
             
     | 
| 
       195 
     | 
    
         
            -
             
     | 
| 
       196 
     | 
    
         
            -
                 
     | 
| 
       197 
     | 
    
         
            -
                 
     | 
| 
       198 
     | 
    
         
            -
             
     | 
| 
       199 
     | 
    
         
            -
             
     | 
| 
       200 
     | 
    
         
            -
               
     | 
| 
       201 
     | 
    
         
            -
             
     | 
| 
       202 
     | 
    
         
            -
             
     | 
| 
       203 
     | 
    
         
            -
                data = 
     | 
| 
       204 
     | 
    
         
            -
                expect(data. 
     | 
| 
       205 
     | 
    
         
            -
              end
         
     | 
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require_relative '../lib/contentstack.rb'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            describe Contentstack::Query do
         
     | 
| 
      
 5 
     | 
    
         
            +
              let(:client) { create_client }
         
     | 
| 
      
 6 
     | 
    
         
            +
              let(:preview_client) { create_preview_client }
         
     | 
| 
      
 7 
     | 
    
         
            +
              let(:category_query) {client.content_type("category").query}
         
     | 
| 
      
 8 
     | 
    
         
            +
              let(:preview_category) {preview_client.content_type("category").query}
         
     | 
| 
      
 9 
     | 
    
         
            +
              let(:product_query) {client.content_type("product").query}
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              it "should get data using `where` method" do
         
     | 
| 
      
 12 
     | 
    
         
            +
                data = category_query.where({title: "Electronics"}).fetch
         
     | 
| 
      
 13 
     | 
    
         
            +
                expect(data.length).to eq 5
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              it "should get data using `regex` method" do
         
     | 
| 
      
 17 
     | 
    
         
            +
                data = category_query.regex("title", "App.*").fetch
         
     | 
| 
      
 18 
     | 
    
         
            +
                expect(data.length).to eq 5
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              it "is preview entry featch" do
         
     | 
| 
      
 22 
     | 
    
         
            +
                preview_client.live_preview_query({hash: 'hash', content_type_uid: 'category'})
         
     | 
| 
      
 23 
     | 
    
         
            +
                data = preview_category.fetch
         
     | 
| 
      
 24 
     | 
    
         
            +
                expect(data.length).to eq 5
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              it "should get data using `less_than` method" do
         
     | 
| 
      
 28 
     | 
    
         
            +
                data = product_query.less_than("price", 150).fetch
         
     | 
| 
      
 29 
     | 
    
         
            +
                expect(data.length).to eq 3
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
              it "should get data using `less_than_or_equal` method" do
         
     | 
| 
      
 33 
     | 
    
         
            +
                data = product_query.less_than_or_equal("price", 166).fetch
         
     | 
| 
      
 34 
     | 
    
         
            +
                expect(data.length).to eq 3
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
              
         
     | 
| 
      
 37 
     | 
    
         
            +
              it "should get data using `greater_than` method" do
         
     | 
| 
      
 38 
     | 
    
         
            +
                data = product_query.greater_than("price", 120).fetch
         
     | 
| 
      
 39 
     | 
    
         
            +
                expect(data.length).to eq 3
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
              it "should get data using `greater_than_or_equal` method" do
         
     | 
| 
      
 43 
     | 
    
         
            +
                data = product_query.greater_than_or_equal("price", 166).fetch
         
     | 
| 
      
 44 
     | 
    
         
            +
                expect(data.length).to eq 3
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
              it "should get data using `not_equal_to` method" do
         
     | 
| 
      
 48 
     | 
    
         
            +
                data = product_query.not_equal_to("price", 166).fetch
         
     | 
| 
      
 49 
     | 
    
         
            +
                expect(data.length).to eq 3
         
     | 
| 
      
 50 
     | 
    
         
            +
              end
         
     | 
| 
      
 51 
     | 
    
         
            +
              
         
     | 
| 
      
 52 
     | 
    
         
            +
              it "should get data using `limit` method" do
         
     | 
| 
      
 53 
     | 
    
         
            +
                data = category_query.limit(2).fetch
         
     | 
| 
      
 54 
     | 
    
         
            +
                expect(data.length).to eq 5
         
     | 
| 
      
 55 
     | 
    
         
            +
              end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
              it "should get data using `skip` method" do
         
     | 
| 
      
 58 
     | 
    
         
            +
                data = category_query.skip(5).fetch
         
     | 
| 
      
 59 
     | 
    
         
            +
                expect(data.length).to eq 5
         
     | 
| 
      
 60 
     | 
    
         
            +
              end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
              it "should get data using `include_count` method" do
         
     | 
| 
      
 63 
     | 
    
         
            +
                data = category_query.include_count.fetch
         
     | 
| 
      
 64 
     | 
    
         
            +
                expect(data.count).not_to be nil
         
     | 
| 
      
 65 
     | 
    
         
            +
                expect(data.count).to eq 5
         
     | 
| 
      
 66 
     | 
    
         
            +
              end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
              it "should get data using `include_metadata` method" do
         
     | 
| 
      
 69 
     | 
    
         
            +
                data = category_query.include_metadata.fetch
         
     | 
| 
      
 70 
     | 
    
         
            +
                expect(data.length).to eq 5
         
     | 
| 
      
 71 
     | 
    
         
            +
              end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
              it "should get data using `only` method with string parameter" do
         
     | 
| 
      
 74 
     | 
    
         
            +
                data = category_query.only("title").fetch
         
     | 
| 
      
 75 
     | 
    
         
            +
                expect(data.first.fields[:title]).not_to be nil
         
     | 
| 
      
 76 
     | 
    
         
            +
                expect(data.first.fields[:uid]).not_to be nil
         
     | 
| 
      
 77 
     | 
    
         
            +
              end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
              it "should get data using `only` method with array parameter" do
         
     | 
| 
      
 80 
     | 
    
         
            +
                data = category_query.only(["title"]).fetch
         
     | 
| 
      
 81 
     | 
    
         
            +
                expect(data.first.fields[:title]).not_to be nil
         
     | 
| 
      
 82 
     | 
    
         
            +
                expect(data.first.fields[:uid]).not_to be nil
         
     | 
| 
      
 83 
     | 
    
         
            +
              end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
              it "should get data using `except` method with string parameter" do
         
     | 
| 
      
 86 
     | 
    
         
            +
                data = category_query.except("category_tags").fetch
         
     | 
| 
      
 87 
     | 
    
         
            +
                expect(data.first.fields[:category_tags]).to be nil
         
     | 
| 
      
 88 
     | 
    
         
            +
              end
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
              it "should get data using `except` method with array parameter" do
         
     | 
| 
      
 91 
     | 
    
         
            +
                data = category_query.except(["description"]).fetch
         
     | 
| 
      
 92 
     | 
    
         
            +
                expect(data.first.fields[:description]).to be nil
         
     | 
| 
      
 93 
     | 
    
         
            +
              end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
              it "should get data using `tags` method" do
         
     | 
| 
      
 96 
     | 
    
         
            +
                data = category_query.tags(["tag1"]).fetch
         
     | 
| 
      
 97 
     | 
    
         
            +
                expect(data.length).to eq 5
         
     | 
| 
      
 98 
     | 
    
         
            +
              end
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
              it "should get data using `contained_in` method" do
         
     | 
| 
      
 101 
     | 
    
         
            +
                data = category_query.contained_in("title", ["Electronics", "Apparel"]).fetch
         
     | 
| 
      
 102 
     | 
    
         
            +
                expect(data.length).to eq 5
         
     | 
| 
      
 103 
     | 
    
         
            +
                expect(data.first.fields[:title]).to eq "Home & Appliances"
         
     | 
| 
      
 104 
     | 
    
         
            +
                expect(data.last.fields[:title]).to eq "Headphones"
         
     | 
| 
      
 105 
     | 
    
         
            +
              end
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
              it "should get data using `not_contained_in` method" do
         
     | 
| 
      
 108 
     | 
    
         
            +
                data = category_query.not_contained_in("title", ["Electronics", "Apparel"]).fetch
         
     | 
| 
      
 109 
     | 
    
         
            +
                expect(data.length).to eq 5
         
     | 
| 
      
 110 
     | 
    
         
            +
              end
         
     | 
| 
      
 111 
     | 
    
         
            +
              
         
     | 
| 
      
 112 
     | 
    
         
            +
              it "should get data using `in` method" do
         
     | 
| 
      
 113 
     | 
    
         
            +
                data = category_query.contained_in("title", ["Electronics", "Apparel"]).fetch
         
     | 
| 
      
 114 
     | 
    
         
            +
                expect(data.length).to eq 5
         
     | 
| 
      
 115 
     | 
    
         
            +
              end
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
              it "should get data using `not_in` method" do
         
     | 
| 
      
 118 
     | 
    
         
            +
                data = category_query.not_contained_in("title", ["Electronics", "Apparel"]).fetch
         
     | 
| 
      
 119 
     | 
    
         
            +
                expect(data.length).to eq 5
         
     | 
| 
      
 120 
     | 
    
         
            +
              end
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
              it "should get data using `ascending` method" do
         
     | 
| 
      
 123 
     | 
    
         
            +
                data = product_query.ascending("price").fetch
         
     | 
| 
      
 124 
     | 
    
         
            +
                expect(data.first.fields[:title]).to eq "Motorola Moto X4"
         
     | 
| 
      
 125 
     | 
    
         
            +
              end
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
              it "should get data using `descending` method" do
         
     | 
| 
      
 128 
     | 
    
         
            +
                data = product_query.descending("price").fetch
         
     | 
| 
      
 129 
     | 
    
         
            +
                expect(data.first.fields[:title]).to eq "Motorola Moto X4"
         
     | 
| 
      
 130 
     | 
    
         
            +
              end
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
              it "should get data using `only` method for reference fields" do
         
     | 
| 
      
 133 
     | 
    
         
            +
                data = product_query.include_reference('categories').only("categories", ["title", "description"]).fetch
         
     | 
| 
      
 134 
     | 
    
         
            +
                expect(data.first.fields[:categories][0][:title]).to eq "Smartphones"
         
     | 
| 
      
 135 
     | 
    
         
            +
              end
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
              it "should get data using `except` method for reference fields" do
         
     | 
| 
      
 138 
     | 
    
         
            +
                data = product_query.include_reference('categories').except("categories", "title").fetch
         
     | 
| 
      
 139 
     | 
    
         
            +
                expect(data.first.fields[:categories][0][:title]).to eq 'Smartphones'
         
     | 
| 
      
 140 
     | 
    
         
            +
              end
         
     | 
| 
      
 141 
     | 
    
         
            +
              
         
     | 
| 
      
 142 
     | 
    
         
            +
              it "should get data using `include_schema` method" do
         
     | 
| 
      
 143 
     | 
    
         
            +
                data = category_query.include_schema.fetch
         
     | 
| 
      
 144 
     | 
    
         
            +
                expect(data.schema).not_to be nil
         
     | 
| 
      
 145 
     | 
    
         
            +
              end
         
     | 
| 
      
 146 
     | 
    
         
            +
             
     | 
| 
      
 147 
     | 
    
         
            +
              it "should get data using `include_content_type` method" do
         
     | 
| 
      
 148 
     | 
    
         
            +
                data = category_query.include_content_type.fetch
         
     | 
| 
      
 149 
     | 
    
         
            +
                expect(data.content_type).not_to be nil
         
     | 
| 
      
 150 
     | 
    
         
            +
              end
         
     | 
| 
      
 151 
     | 
    
         
            +
              
         
     | 
| 
      
 152 
     | 
    
         
            +
              it "should get data using `include_reference` method" do
         
     | 
| 
      
 153 
     | 
    
         
            +
                data = product_query.include_reference('categories').fetch
         
     | 
| 
      
 154 
     | 
    
         
            +
                puts data.first.get("categories.title")
         
     | 
| 
      
 155 
     | 
    
         
            +
                expect(data.first.fields[:categories][0][:title]).not_to be nil
         
     | 
| 
      
 156 
     | 
    
         
            +
              end
         
     | 
| 
      
 157 
     | 
    
         
            +
              
         
     | 
| 
      
 158 
     | 
    
         
            +
              it "should get data using `include_owner` method" do
         
     | 
| 
      
 159 
     | 
    
         
            +
                data = product_query.include_owner.fetch
         
     | 
| 
      
 160 
     | 
    
         
            +
                expect(data.first.fields[:_owner]).not_to be nil
         
     | 
| 
      
 161 
     | 
    
         
            +
              end
         
     | 
| 
      
 162 
     | 
    
         
            +
              
         
     | 
| 
      
 163 
     | 
    
         
            +
              it "should get data using `include_owner` method" do
         
     | 
| 
      
 164 
     | 
    
         
            +
                data = product_query.include_fallback.fetch
         
     | 
| 
      
 165 
     | 
    
         
            +
                expect(data.first.fields[:locale]).not_to be nil
         
     | 
| 
      
 166 
     | 
    
         
            +
              end
         
     | 
| 
      
 167 
     | 
    
         
            +
             
     | 
| 
      
 168 
     | 
    
         
            +
              it "should get data using `include_draft` method" do
         
     | 
| 
      
 169 
     | 
    
         
            +
                data = category_query.include_draft.fetch
         
     | 
| 
      
 170 
     | 
    
         
            +
                expect(data.length).to eq 5
         
     | 
| 
      
 171 
     | 
    
         
            +
              end
         
     | 
| 
      
 172 
     | 
    
         
            +
             
     | 
| 
      
 173 
     | 
    
         
            +
              it "should get data using `search` method" do
         
     | 
| 
      
 174 
     | 
    
         
            +
                data = category_query.search("App").fetch
         
     | 
| 
      
 175 
     | 
    
         
            +
                expect(data.length).to eq 5
         
     | 
| 
      
 176 
     | 
    
         
            +
              end
         
     | 
| 
      
 177 
     | 
    
         
            +
             
     | 
| 
      
 178 
     | 
    
         
            +
              it "should get data using `count` method" do
         
     | 
| 
      
 179 
     | 
    
         
            +
                data = category_query.count
         
     | 
| 
      
 180 
     | 
    
         
            +
                expect(data).to eq 5
         
     | 
| 
      
 181 
     | 
    
         
            +
              end
         
     | 
| 
      
 182 
     | 
    
         
            +
             
     | 
| 
      
 183 
     | 
    
         
            +
              it "should get data using `exists` method" do
         
     | 
| 
      
 184 
     | 
    
         
            +
                data = category_query.exists?('description').fetch
         
     | 
| 
      
 185 
     | 
    
         
            +
                expect(data.length).to eq 5
         
     | 
| 
      
 186 
     | 
    
         
            +
              end
         
     | 
| 
      
 187 
     | 
    
         
            +
              
         
     | 
| 
      
 188 
     | 
    
         
            +
              it "should get data using `not_exists` method" do
         
     | 
| 
      
 189 
     | 
    
         
            +
                data = product_query.not_exists?('banner_image').fetch
         
     | 
| 
      
 190 
     | 
    
         
            +
                expect(data.length).to eq 3
         
     | 
| 
      
 191 
     | 
    
         
            +
              end
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
              it "should get data using `and` method" do
         
     | 
| 
      
 194 
     | 
    
         
            +
                q1 = client.content_type("category").query.regex("title", "App.*")
         
     | 
| 
      
 195 
     | 
    
         
            +
                q2 = client.content_type("category").query.where({"description"=>"Appliances Category"})
         
     | 
| 
      
 196 
     | 
    
         
            +
                data = category_query.and([q1,q2]).fetch
         
     | 
| 
      
 197 
     | 
    
         
            +
                expect(data.length).to eq 5
         
     | 
| 
      
 198 
     | 
    
         
            +
              end
         
     | 
| 
      
 199 
     | 
    
         
            +
             
     | 
| 
      
 200 
     | 
    
         
            +
              it "should get data using `or` method" do
         
     | 
| 
      
 201 
     | 
    
         
            +
                q1 = client.content_type("category").query.regex("title", "App.*")
         
     | 
| 
      
 202 
     | 
    
         
            +
                q2 = client.content_type("category").query.regex("description", "App*")
         
     | 
| 
      
 203 
     | 
    
         
            +
                data = category_query.or([q1,q2]).fetch
         
     | 
| 
      
 204 
     | 
    
         
            +
                expect(data.length).to eq 5
         
     | 
| 
      
 205 
     | 
    
         
            +
              end
         
     | 
| 
      
 206 
     | 
    
         
            +
             
     | 
| 
      
 207 
     | 
    
         
            +
              it "should set locale the in the request query" do
         
     | 
| 
      
 208 
     | 
    
         
            +
                data =  product_query.locale('en-us')
         
     | 
| 
      
 209 
     | 
    
         
            +
                expect(data.query[:locale]).to eq 'en-us'
         
     | 
| 
      
 210 
     | 
    
         
            +
              end
         
     | 
| 
       206 
211 
     | 
    
         
             
            end
         
     |