iron-cms 0.2.1 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3dc16db2bf8c1ee5f0cca129113aed94f3064d405ae13b7a8a80cc2f601c4a4f
4
- data.tar.gz: ff04983432ca9fce51945b29625144685b082047278f6afda51a057e70040b5a
3
+ metadata.gz: 8d019cb05573756b7d61bd6eaafe23f1bfecc02df82b9bbb0533909aa432d2aa
4
+ data.tar.gz: 5a71d2e8cded815151c6d2bf4c8b349340a532aab46428e3841f0289633ec473
5
5
  SHA512:
6
- metadata.gz: 8f1b195f43f04b198e29f18c8bae4dde22424dd869435db76c1e1ea644f8756e67ca0f0cd6f81b4b83410687c664e14952448b599125630c12a13dc547f744a8
7
- data.tar.gz: c3c3fa9ae10cb698dac50abdac3f36fd6d0342f2ca7800e8d42445330fdb7863faab8a562b57d2d432a71e50ba7a12138d90592b77557a455e55a0899bfb5fba
6
+ metadata.gz: edd018af4978ff7bf85c1dae55ea57e99b272444bed821812b4e2bba5a887c46db039f37338f565999d2260ff0e0c701c51ae9edfd43141a49cbd6129d01c758
7
+ data.tar.gz: 5b49d870736b4ecf0ca3b4d497be6c7697d94ab2bf19f8441458d175de08e60f8f777872acb05b327840b1a39a8a4150c5c68aa7fc19478dce2f397dc5c2d86b
data/README.md CHANGED
@@ -9,6 +9,7 @@ Iron is a flexible CMS engine for Rails apps
9
9
  Iron CMS allows you to publish content types to your website. To set this up:
10
10
 
11
11
  1. **Install the pages controller** in your application:
12
+
12
13
  ```bash
13
14
  bin/rails g iron:pages
14
15
  ```
@@ -19,6 +20,7 @@ Iron CMS allows you to publish content types to your website. To set this up:
19
20
  - Create a default view template
20
21
 
21
22
  2. **Create custom templates** for your content types:
23
+
22
24
  ```bash
23
25
  bin/rails g iron:template article
24
26
  ```
@@ -60,6 +62,7 @@ Use `iron_picture_tag` for optimal image delivery:
60
62
  ```
61
63
 
62
64
  This automatically:
65
+
63
66
  - Generates responsive variants (150w, 320w, 640w, 1024w, 1920w)
64
67
  - Serves modern formats (AVIF, WebP) with automatic fallback
65
68
  - Adds proper dimensions to prevent layout shift
@@ -93,6 +96,38 @@ For cases where you need a basic responsive image without format optimization:
93
96
 
94
97
  This generates a standard `<img>` with srcset but without modern format variants.
95
98
 
99
+ ### Testing
100
+
101
+ Iron provides test fixtures to populate your test database with CMS schema and content, eliminating the need to stub the SDK in your tests.
102
+
103
+ #### Generating Fixtures
104
+
105
+ Generate test fixtures from your development database (or production if you prefer):
106
+
107
+ ```bash
108
+ bin/rails iron:fixtures:generate
109
+ ```
110
+
111
+ This creates two files in `test/fixtures/iron/`:
112
+
113
+ - `schema.tar.gz` - Content types, field definitions, and block definitions
114
+ - `content.tar.gz` - All entries and their field data
115
+
116
+ Regenerate these fixtures whenever you make changes to your CMS schema or content that you want reflected in tests.
117
+
118
+ #### Using Fixtures in Tests
119
+
120
+ Load the fixtures in your `test/test_helper.rb`:
121
+
122
+ ```ruby
123
+ class ActiveSupport::TestCase
124
+ fixtures :all
125
+ Iron::TestFixtures.load
126
+ end
127
+ ```
128
+
129
+ The fixtures are loaded once at the start of your test suite. Rails' transactional tests provide test isolation by rolling back changes after each test.
130
+
96
131
  ## Installation
97
132
 
98
133
  Add this line to your application's Gemfile:
@@ -174,6 +209,7 @@ To release a new version of the Iron gem:
174
209
  - Update `CHANGELOG.md` with the changes for the new version
175
210
 
176
211
  2. **Commit and tag the release:**
212
+
177
213
  ```bash
178
214
  git add -A
179
215
  git commit -m "chore: release version X.Y.Z"
@@ -181,11 +217,13 @@ To release a new version of the Iron gem:
181
217
  ```
182
218
 
183
219
  3. **Push to GitHub:**
220
+
184
221
  ```bash
185
222
  git push origin main --tags
186
223
  ```
187
224
 
188
225
  4. **Build and publish the gem:**
226
+
189
227
  ```bash
190
228
  gem build iron.gemspec
191
229
  gem push iron-X.Y.Z.gem
@@ -0,0 +1,50 @@
1
+ require "stringio"
2
+
3
+ module Iron
4
+ module TestFixtures
5
+ class << self
6
+ def load
7
+ return if @loaded
8
+
9
+ fixture_path = Rails.root.join("test/fixtures/iron")
10
+ schema_file = fixture_path.join("schema.tar.gz")
11
+ content_file = fixture_path.join("content.tar.gz")
12
+
13
+ if schema_file.exist?
14
+ load_schema(schema_file)
15
+ else
16
+ Rails.logger.warn "Iron test fixture not found: #{schema_file}"
17
+ end
18
+
19
+ if content_file.exist?
20
+ load_content(content_file)
21
+ else
22
+ Rails.logger.warn "Iron test fixture not found: #{content_file}"
23
+ end
24
+
25
+ @loaded = true
26
+ end
27
+
28
+ private
29
+
30
+ def load_schema(file_path)
31
+ File.open(file_path, "rb") do |file|
32
+ result = SchemaImporter.import(file, mode: "merge")
33
+ unless result.success?
34
+ raise "Failed to load Iron schema fixtures: #{result.errors.join(', ')}"
35
+ end
36
+ end
37
+ end
38
+
39
+ def load_content(file_path)
40
+ File.open(file_path, "rb") do |file|
41
+ archive = Archive.from_file(file)
42
+ result = ContentImport.import(archive)
43
+ unless result.success?
44
+ raise "Failed to load Iron content fixtures: #{result.errors.join(', ')}"
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
data/lib/iron/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Iron
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/iron.rb CHANGED
@@ -3,6 +3,7 @@ require "iron/engine"
3
3
  require "iron/cva"
4
4
  require "iron/sdk"
5
5
  require "iron/global_id/instance_scoped_locator"
6
+ require "iron/test_fixtures"
6
7
 
7
8
  module Iron
8
9
  # Your code goes here...
@@ -0,0 +1,24 @@
1
+ namespace :iron do
2
+ namespace :fixtures do
3
+ desc "Generate test fixtures from current database"
4
+ task generate: :environment do
5
+ fixture_dir = Rails.root.join("test/fixtures/iron")
6
+ FileUtils.mkdir_p(fixture_dir)
7
+
8
+ schema_path = fixture_dir.join("schema.tar.gz")
9
+ content_path = fixture_dir.join("content.tar.gz")
10
+
11
+ puts "Exporting Iron schema to #{schema_path}..."
12
+ schema_tar = Iron::SchemaExporter.export
13
+ File.binwrite(schema_path, schema_tar)
14
+
15
+ puts "Exporting Iron content to #{content_path}..."
16
+ content_archive = Iron::ContentExport.export
17
+ content_archive.to_file(content_path)
18
+
19
+ puts "Test fixtures generated successfully!"
20
+ puts " - Schema: #{schema_path}"
21
+ puts " - Content: #{content_path}"
22
+ end
23
+ end
24
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iron-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Massimo De Marchi
@@ -427,8 +427,10 @@ files:
427
427
  - lib/iron/lexorank/utils.rb
428
428
  - lib/iron/routing.rb
429
429
  - lib/iron/sdk.rb
430
+ - lib/iron/test_fixtures.rb
430
431
  - lib/iron/version.rb
431
432
  - lib/puma/plugin/iron_tailwindcss.rb
433
+ - lib/tasks/iron_tasks.rake
432
434
  homepage: https://github.com/inkOfPixel/iron
433
435
  licenses:
434
436
  - MIT