cortex 0.1.1 → 0.1.3

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: 02be4dc6153e80f279a2fd206836a381fefc3795f041f374cba3432b4a2635e2
4
- data.tar.gz: 9030f02d775228201076a839717fbc448865298cb10439ea7fdd4ad1cc0e793f
3
+ metadata.gz: 4426b62937bf51d4a6573548dd8d609416a79ff5b30a248ebd2c0ce886b47f59
4
+ data.tar.gz: 42032a40d2798d5cffbf20cefad8deaed73eafafd56cb16bb16f5b7cb0cb48b4
5
5
  SHA512:
6
- metadata.gz: 74e62c6f98e35e21d3b401664d8cbee5ed0cccbf8e3d5f10099703324dd947250b412181f7972f4086b4b5b907b6ecf5dfdfd1ef211fa0c9e4957ee55db9f8a9
7
- data.tar.gz: 07f749ee18a1b26dcac66f7aa34a8b4b8bc261a7a380614e7b3b0ce9d151d3efa127ceeb7e1725f3996bb6e791a8f82a512d205f90e8e43e743c8e23f8880862
6
+ metadata.gz: 2055aadd5e0c975dc53b3f2f300a2329cfd967c6b3255f1a24e2d69d02bfb84c073b701c73d7897ea82e1fa9c458269c3f2e82c28e68201cc5c8f8076632dbc5
7
+ data.tar.gz: c4f75eca590607f743f4b0abb994fa9d8a332be1dea0a2307411543d65cfb70fe9b6e594c01e312761a99da4525305c0b70482c25cb9edfbc0a155b10ec61603
@@ -0,0 +1,103 @@
1
+ # Ruby CircleCI 2.0 configuration file
2
+ #
3
+ # Check https://circleci.com/docs/2.0/language-ruby/ for more details
4
+ #
5
+ version: 2
6
+ jobs:
7
+ build:
8
+ environment:
9
+ APP_SECRET: eff4949db97d2f67e375b25784984a4c36bb3d7103a4a32562204cba199b01919903635efb901b78f04c5bb55ef5079fca664b35a03b5c59eb6c2721972251c5
10
+ DEVISE_SECRET: 2af89dd48125b17425532c09c78c051923b0574ac3a1175bbf18c40c8c147c2ba54736323d436b11003a8cc6ef18165a46d7128cfc672f14ca611615e13ba7f4
11
+ GRAPHQL_URL: /graphql
12
+ REDIS_NAMESPACE: cortex_test
13
+ CACHE_URL: redis://localhost:6379/0/cache
14
+ SESSION_STORE_URL: redis://localhost:6379/0/cache
15
+ ELASTICSEARCH_ADDRESS: localhost:9200
16
+ DATABASE_NAME: cortex_starter_test
17
+ DATABASE_USERNAME: root
18
+ DATABASE_HOST: localhost
19
+ DATABASE_PORT: 5432
20
+
21
+ docker:
22
+ # specify the version you desire here
23
+ - image: circleci/ruby:2.5.1-node-browsers
24
+
25
+ # Specify service dependencies here if necessary
26
+ # CircleCI maintains a library of pre-built images
27
+ # documented at https://circleci.com/docs/2.0/circleci-images/
28
+ - image: circleci/postgres:10.4-alpine
29
+ - image: redis:4.0-alpine
30
+ - image: docker.elastic.co/elasticsearch/elasticsearch:5.6.10
31
+ environment:
32
+ xpack.security.enabled: false
33
+
34
+ working_directory: ~/repo
35
+
36
+ steps:
37
+ - checkout
38
+
39
+ # Download and cache dependencies
40
+ - restore_cache:
41
+ name: Restore Yarn Package Cache
42
+ keys:
43
+ - yarn-packages-{{ checksum "yarn.lock" }}
44
+ - run:
45
+ name: Install Dependencies
46
+ command: yarn install
47
+ - save_cache:
48
+ name: Save Yarn Package Cache
49
+ key: yarn-packages-{{ checksum "yarn.lock" }}
50
+ paths:
51
+ - ~/.cache/yarn
52
+
53
+ - restore_cache:
54
+ keys:
55
+ - v1-dependencies-{{ checksum "Gemfile.lock" }}
56
+ # fallback to using the latest cache if no exact match is found
57
+ - v1-dependencies-
58
+ - run:
59
+ name: install dependencies
60
+ command: |
61
+ bundle install --jobs=4 --retry=3 --path vendor/bundle
62
+ - save_cache:
63
+ paths:
64
+ - ./vendor/bundle
65
+ key: v1-dependencies-{{ checksum "Gemfile.lock" }}
66
+
67
+ - run:
68
+ name: install dockerize
69
+ command: wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && sudo tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
70
+ environment:
71
+ DOCKERIZE_VERSION: v0.3.0
72
+ - run:
73
+ name: Wait for Postgres
74
+ command: dockerize -wait tcp://localhost:5432 -timeout 2m
75
+ - run:
76
+ name: Wait for Redis
77
+ command: dockerize -wait tcp://localhost:6379 -timeout 2m
78
+ - run:
79
+ name: Wait for ElasticSearch
80
+ command: dockerize -wait tcp://localhost:9200 -timeout 2m
81
+
82
+ # Database setup
83
+ - run: spec/dummy/bin/setup
84
+
85
+ # run tests!
86
+ - run:
87
+ name: run tests
88
+ command: |
89
+ mkdir /tmp/test-results
90
+ TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
91
+
92
+ spec/dummy/bin/rspec --format progress \
93
+ --format RspecJunitFormatter \
94
+ --out /tmp/test-results/rspec.xml \
95
+ --format progress \
96
+ $TEST_FILES
97
+
98
+ # collect reports
99
+ - store_test_results:
100
+ path: /tmp/test-results
101
+ - store_artifacts:
102
+ path: /tmp/test-results
103
+ destination: test-results
@@ -46,13 +46,14 @@ further improvements or alternatives, or the community at large may have input.
46
46
  Some things that will increase the chances that your pull request will be accepted:
47
47
 
48
48
  * Write [good tests][tests]
49
- * Write [good commit messages][commit]
49
+ * Write [good][good-commit], [semantic][semantic-commit] commit messages
50
50
  * Be consistent
51
51
  * If applicable, suggest additional options or alternatives, follow-up issues or potential future improvements
52
52
 
53
- [issue]: https://github.com/cbdr/cortex/issues
53
+ [issue]: https://github.com/cortex-cms/cortex/issues
54
54
  [tests]: http://betterspecs.org
55
- [commit]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
56
- [setup]: https://github.com/cbdr/cortex#setup
57
- [pr]: https://github.com/cbdr/cortex/compare
58
- [test-suite]: https://github.com/cbdr/cortex#running-test-suite
55
+ [good-commit]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
56
+ [semantic-commit]: https://seesparkbox.com/foundry/semantic_commit_messages
57
+ [setup]: https://docs.cortexcms.org/basics/setup/manual-setup
58
+ [pr]: https://github.com/cortex-cms/cortex/compare
59
+ [test-suite]: https://docs.cortexcms.org/basics/setup/core-and-plugin-development#running-test-suite
data/Gemfile CHANGED
@@ -78,6 +78,7 @@ group :test do
78
78
  gem 'json_spec', '~> 1.1'
79
79
  gem 'rspec-sidekiq', '~> 3.0'
80
80
  gem 'shoulda-matchers', '~> 3.1'
81
+ gem "rspec_junit_formatter"
81
82
 
82
83
  # Coverage
83
84
  gem 'simplecov'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cortex (0.1.0)
4
+ cortex (0.1.3)
5
5
  addressable (~> 2.5.2)
6
6
  awesome_nested_set (~> 3.1.4)
7
7
  breadcrumbs_on_rails (~> 3.0.1)
@@ -485,6 +485,8 @@ GEM
485
485
  rspec-core (~> 3.0, >= 3.0.0)
486
486
  sidekiq (>= 2.4.0)
487
487
  rspec-support (3.7.1)
488
+ rspec_junit_formatter (0.4.1)
489
+ rspec-core (>= 2, < 4, != 2.12.0)
488
490
  ruby-graphviz (1.2.3)
489
491
  ruby-prof (0.17.0)
490
492
  ruby_dep (1.5.0)
@@ -588,6 +590,7 @@ DEPENDENCIES
588
590
  redis-rails (~> 5.0)
589
591
  rspec-rails
590
592
  rspec-sidekiq (~> 3.0)
593
+ rspec_junit_formatter
591
594
  sass-rails (~> 5.0)
592
595
  shoulda-matchers (~> 3.1)
593
596
  sidekiq (~> 5.1.3)
data/README.md CHANGED
@@ -1,226 +1,15 @@
1
- # Cortex CMS [![Build Status](https://semaphoreci.com/api/v1/projects/ec90715a-da8f-4960-bb64-f371850f9c98/813409/shields_badge.svg)](https://semaphoreci.com/content-enablement/cortex) [![Code Climate](https://codeclimate.com/repos/53f62c2869568018180036c9/badges/78e3c3c865b118bbd72b/gpa.svg)](https://codeclimate.com/repos/53f62c2869568018180036c9/feed) [![Test Coverage](https://codeclimate.com/repos/53f62c2869568018180036c9/badges/78e3c3c865b118bbd72b/coverage.svg)](https://codeclimate.com/repos/53f62c2869568018180036c9/coverage) [![Documentation Status](https://www.gitbook.com/button/status/book/cortex-cms/cortex-cms)](https://docs.cortexcms.org/)
1
+ # Cortex CMS Engine [![CircleCI](https://circleci.com/gh/cortex-cms/cortex.svg?style=svg)](https://circleci.com/gh/cortex-cms/cortex) [![Code Climate](https://codeclimate.com/repos/53f62c2869568018180036c9/badges/78e3c3c865b118bbd72b/gpa.svg)](https://codeclimate.com/repos/53f62c2869568018180036c9/feed) [![Test Coverage](https://codeclimate.com/repos/53f62c2869568018180036c9/badges/78e3c3c865b118bbd72b/coverage.svg)](https://codeclimate.com/repos/53f62c2869568018180036c9/coverage)
2
2
  <img align="right" height="150"
3
3
  src="https://hiring-assets.careerbuilder.com/branding/cortex-logo.svg"
4
4
  alt="Cortex CMS Logo">
5
5
 
6
- Cortex CMS is a [multitenant](https://en.wikipedia.org/wiki/Multitenancy) identity, content distribution/management and reporting platform built by the [Content Enablement][cb-ce-github] team at [CareerBuilder](https://github.com/careerbuilder). Its purpose is to provide central infrastructure for next-generation applications; exposing a single point of management while enabling quicker build-out of new software.
6
+ Cortex CMS is a [multitenant](https://en.wikipedia.org/wiki/Multitenancy) identity, [custom content](https://docs.cortexcms.org/glossary#custom-content-cms) distribution/management and reporting platform built by the [Content Enablement][cb-ce-github] team at [CareerBuilder](https://github.com/careerbuilder). Its purpose is to provide central infrastructure for next-generation applications; exposing a single point of management while enabling quicker build-out of new software.
7
7
 
8
- Cortex follows a decentralized, API-only architecture - it is *not* built like Wordpress or Drupal, which are considered monolithic, all-in-one solutions.
8
+ Cortex adheres to a headless, API-only architecture - it avoids a monolithic, all-in-one architecture associated with CMSs like WordPress or Drupal.
9
9
 
10
- ## Table of Contents
10
+ ## Documentation
11
11
 
12
- - [Setup](#setup)
13
- - [Environment](#environment)
14
- - [Dependencies](#dependencies)
15
- - [System](#system)
16
- - [OS X](#os-x)
17
- - [Linux](#linux)
18
- - [Application](#application)
19
- - [Database](#database)
20
- - [Server](#server)
21
- - [Deployment](#deployment)
22
- - [Running Test Suite](#running-test-suite)
23
- - [API](#api)
24
- - [Documentation](#documentation)
25
- - [Consuming Cortex](#consuming-cortex)
26
- - [Authorization](#authorization)
27
- - [Content](#content)
28
- - [Localizations](#localizations)
29
- - [Exceptions](#exceptions)
30
- - [Applications Using Cortex](#applications-using-cortex)
31
- - [Troubleshooting](#troubleshooting)
32
- - [Contributing](#contributing)
33
- - [License](#license)
34
- - [Copyright](#copyright)
35
-
36
- ## Setup
37
-
38
- ### Environment
39
-
40
- Copy and rename the example `.env.example` file as `.env` and modify it to match your environment.
41
-
42
- For a rudimentary setup, these variables should be configured:
43
-
44
- * Execute `$ bundle exec rails secret` twice to generate both an `APP_SECRET` and `DEVISE_SECRET`
45
- * If the superuser isn't used for the app databases, the `DATABASE_USERNAME` and `DATABASE_PASSWORD` should be set accordingly.
46
-
47
- ### Dependencies
48
-
49
- #### System
50
-
51
- ##### OS X
52
-
53
- * Install the Xcode Command Line tools:
54
-
55
- ```sh
56
- $ xcode-select --install
57
- ```
58
-
59
- * Install all Cortex system-wide dependencies (and the `readline` Ruby/`byebug` build dependency) using [Homebrew](http://brew.sh/) from the `Brewfile` via `$ brew install $(cat Brewfile|grep -v "#")`
60
- * Install Ruby via [rbenv](https://github.com/sstephenson/rbenv) or [rvm](https://rvm.io/).
61
- * Enable system agents:
62
-
63
- ```sh
64
- $ ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
65
- $ ln -sfv /usr/local/opt/elasticsearch/*.plist ~/Library/LaunchAgents
66
- $ ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
67
- ```
68
-
69
- and start them with `brew services`:
70
-
71
- ```sh
72
- $ brew services start postgresql
73
- $ brew services start elasticsearch
74
- $ brew services start redis
75
- ```
76
-
77
- or `launchctl`:
78
-
79
- ```sh
80
- $ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
81
- $ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist
82
- $ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
83
- ```
84
-
85
- ##### Linux
86
-
87
- * Install all Cortex system-wide dependencies (and the `readline` Ruby/`byebug` build dependency) using your distribution's package manager (`pacman`, `apt-get`, `yum`, etc). For example, with Ubuntu's `apt-get`:
88
-
89
- ```sh
90
- $ apt-get install libreadline6-dev postgresql postgresql-contrib redis-server openjdk-8-jre imagemagick jpegoptim ghostscript
91
- ```
92
-
93
- Ubuntu and Redhat/Fedora do not have an official `elasticsearch` package - you must use Elasticsearch's repositories for [APT](https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html) or [RPM](https://www.elastic.co/guide/en/elasticsearch/reference/current/rpm.html) or follow these [manual instructions](https://www.elastic.co/guide/en/elasticsearch/reference/current/_installation.html). The same goes for `phantomjs`. Build from [source](http://phantomjs.org/download.html) or use a [PPA](https://launchpad.net/ubuntu/+ppas?name_filter=phantomjs). Other Linux distributions likely have these as prebuilt packages in their official or user repositories.
94
-
95
- * Install Ruby via [rbenv](https://github.com/sstephenson/rbenv) or [rvm](https://rvm.io/).
96
- * Enable system agents using your distribution's service manager frontend, which is likely `systemd`'s frontend, `systemctl`:
97
-
98
- ```sh
99
- $ systemctl enable postgresql
100
- $ systemctl enable elasticsearch
101
- $ systemctl enable redis
102
- ```
103
-
104
- and start them with `systemctl`:
105
-
106
- ```sh
107
- $ systemctl start postgresql
108
- $ systemctl start elasticsearch
109
- $ systemctl start redis
110
- ```
111
-
112
- #### Application
113
-
114
- * Install Bundler and its dependencies:
115
-
116
- ```sh
117
- $ gem install bundler && bundle install
118
- ```
119
-
120
- * Install `node`, then run Yarn to install frontend dependencies:
121
-
122
- ```sh
123
- $ yarn install
124
- ```
125
-
126
- ### Database
127
-
128
- * Create databases:
129
-
130
- ```sh
131
- $ bin/rails db:create
132
- ```
133
-
134
- * Initialize the schema:
135
-
136
- ```sh
137
- $ bin/rails db:schema:load
138
- ```
139
-
140
- * Seed database with a top-level tenant, the superuser and Custom Content data, then rebuild the ElasticSearch index:
141
-
142
- ```sh
143
- $ bundle exec rake db:seed
144
- $ bundle exec rake cortex:core:db:reseed
145
- $ bundle exec rake cortex:rebuild_indexes
146
- ```
147
-
148
- ### Server
149
-
150
- Start Cortex, Sidekiq and live rebuild/reload via Foreman:
151
-
152
- ```sh
153
- $ gem install foreman
154
- $ foreman start -f Procfile.dev-server
155
- ```
156
-
157
- The admin interface should now be accessible locally on port `3000`. To access Cortex as superadmin, login as `admin@cortexcms.org` with password `welcome1`.
158
-
159
- ### Deployment
160
-
161
- Deploying the `development` environment as a non-local server will require an additional environmental variable be set:
162
-
163
- ```shell
164
- DEPLOYED=true
165
- ```
166
-
167
- This will configure various things to behave normally in a deployed scenario.
168
-
169
- ## Running Test Suite
170
-
171
- Initialize the test database:
172
-
173
- ```sh
174
- $ RAILS_ENV=test bundle exec rake db:schema:load db:seed cortex:core:db:reseed
175
- $ RAILS_ENV=test bundle exec rake cortex:rebuild_indexes
176
- ```
177
-
178
- To run Ruby and JS specs, utilize:
179
-
180
- ```sh
181
- $ RAILS_ENV=test bundle exec rake spec
182
- $ RAILS_ENV=test bundle exec rake spec:javascript
183
- ```
184
-
185
- ## API
186
-
187
- ### Documentation
188
-
189
- Cortex's live API documentation is available via Swagger. This contains specific endpoints, parameters, and response models.
190
-
191
- SwaggerUI is provided at [http://docs.api.cbcortex.com/](http://docs.api.cbcortex.com).
192
-
193
- Swagger Endpoints are available at [http://api.cbcortex.com/api/v1/swagger_doc.json](http://api.cbcortex.com/api/v1/swagger_doc.json).
194
-
195
- ## Consuming Cortex
196
-
197
- ### Authorization
198
-
199
- Cortex's API utilizes [OAuth2](https://tools.ietf.org/html/rfc6749) for Authentication and Authorization. Client Credentials and Authorization Code [grant types](http://alexbilbie.com/2013/02/a-guide-to-oauth-2-grants/) are supported. Want to get up and running quickly with OAuth? Use Cortex's [Ruby client](https://github.com/cortex-cms/cortex-client-ruby) or [OmniAuth strategy](https://github.com/cb-talent-development/omniauth-cortex) for Client Credentials and Authorization Code grants, respectively.
200
-
201
- Before an application can consume any data, OAuth credentials must be created for the consuming application in the 'Applications' section of the Cortex admin interface.
202
-
203
- ### Content
204
-
205
- Content can be consumed from a feed or via the resource's endpoint directly. Use the [cortex-client](https://github.com/cbdr/cortex-client) gem to easily consume any content resource and use it in your application.
206
-
207
- ### Localizations
208
-
209
- Localizations can be consumed via the client or via [i18n-backend-cortex](https://github.com/cortex-cms/i18n-backend-cortex), which allows easy localization for Rails applications.
210
-
211
- ### Exceptions
212
-
213
- If a consuming or companion application would like to produce Cortex-equivalent exceptions, use the [cortex-exceptions](https://github.com/cb-talent-development/cortex-exceptions) gem.
214
-
215
- ## Applications Using Cortex
216
-
217
- * [Advice and Resources](https://github.com/cbdr/consumer-main/) - Simple Jobseeker Resources platform built atop the Consumer Web site utilizing Legacy Cortex Posts and Rails. Content will eventually be dynamically dispersed across site (result pages, description pages, etc) [Live Site](https://www.careerbuilder.com/advice)
218
- * [Employer](https://github.com/cbdr/employer) - Redesigned Employer Marketing platform utilizing Legacy Cortex Webpages/Snippets and Rails. [Live Site](https://hiring.careerbuilder.com/)
219
- * [CB1 Lander Shell](https://github.com/cbdr/cb1-lander-shell) - Platform for hosting lander pages and experiments, utilizing Legacy Cortex Posts and Sinatra. [Live Site](http://corporate.careerbuilder.com/)
220
- * [CareerBuilder.com](https://github.com/cbdr/consumer-main) - The main Consumer Web site for CB.com uses Legacy Cortex Posts for the [Privacy](https://www.careerbuilder.com/privacy) and [Terms of Service](https://www.careerbuilder.com/terms) pages.
221
-
222
- ## Troubleshooting
223
- * For OS X / homebrew users: Run `which node` to ensure node is properly linked. The path shown should match homebrew's default installation path (run `which brew` to reveal this). If its not, then run `brew link node` and follow the instructions.
12
+ Cortex CMS features a comprehensive [documentation portal](https://docs.cortexcms.org). To get started, refer to the [manual setup guide](https://docs.cortexcms.org/basics/setup/manual-setup).
224
13
 
225
14
  ## Contributing
226
15
 
@@ -234,6 +23,6 @@ Cortex utilizes the Apache 2.0 License. See [LICENSE](LICENSE.md) for details.
234
23
 
235
24
  ## Copyright
236
25
 
237
- Copyright (c) 2018 CareerBuilder, LLC.
26
+ Copyright (c) CareerBuilder, LLC.
238
27
 
239
28
  [cb-ce-github]: https://github.com/cb-talent-development "Content Enablement on GitHub"
@@ -28,47 +28,57 @@ module Cortex
28
28
  @content_item = content_type.content_items.find_by_tenant(current_user.active_tenant).find_by_id(params[:id])
29
29
  @wizard = wizard_decorator(@content_item.content_type)
30
30
 
31
- title = @content_item.field_items.find { |field_item| field_item.field.name == 'Title' }.data['text'] # TODO: refactor this hardcoded Field reference
31
+ title = @content_item.field_items.find {|field_item| field_item.field.name == 'Title'}.data['text'] # TODO: refactor this hardcoded Field reference
32
32
  add_breadcrumb content_type.name.pluralize, :content_type_content_items_path
33
33
  add_breadcrumb title
34
34
  add_breadcrumb 'Edit'
35
35
  end
36
36
 
37
37
  def update
38
- begin
39
- update_content_item
40
- rescue ActiveRecord::RecordInvalid => e
41
- flash[:warning] = validation_message(e.message)
42
- @content_item = content_item_reload(content_type.content_items.find_by_id(params[:id]))
43
- @wizard = wizard_decorator(@content_item.content_type)
38
+ update_content_item
39
+ .with_step_args(
40
+ execute_content_item_state_change: [state: params[:content_item][:state]]
41
+ )
42
+ .call(id: params[:id], content_type: content_type,
43
+ content_item_params: content_item_params, current_user: current_user) do |m|
44
+ m.success do |content_item|
45
+ flash[:success] = "#{content_type.name} successfully updated"
46
+ redirect_to content_type_content_items_path
47
+ end
44
48
 
45
- title = @content_item.field_items.find { |field_item| field_item.field.name == 'Title' }.data['text'] # TODO: refactor this hardcoded Field reference
46
- add_breadcrumb content_type.name.pluralize, :content_type_content_items_path
47
- add_breadcrumb title
48
- add_breadcrumb 'Edit'
49
+ m.failure :persist_content_item do |errors|
50
+ flash[:warning] = clean_error_messages(errors.full_messages)
51
+ render_update_content_item_error
52
+ end
49
53
 
50
- render :edit
51
- else
52
- flash[:success] = "Hooray! #{content_type.name} Updated!"
53
- redirect_to content_type_content_items_path
54
+ m.failure do |error|
55
+ flash[:warning] = ['Unknown System Error']
56
+ render_update_content_item_error
57
+ end
54
58
  end
55
59
  end
56
60
 
57
61
  def create
58
- begin
59
- create_content_item
60
- rescue ActiveRecord::RecordInvalid => e
61
- flash[:warning] = validation_message(e.message)
62
- @content_item = content_item_reload(content_type.content_items.new)
63
- @wizard = wizard_decorator(@content_item.content_type)
62
+ create_content_item
63
+ .with_step_args(
64
+ execute_content_item_state_change: [state: params[:content_item][:state]]
65
+ )
66
+ .call(id: params[:id], content_type: content_type,
67
+ content_item_params: content_item_params, current_user: current_user) do |m|
68
+ m.success do |content_item|
69
+ flash[:success] = "#{content_type.name} successfully created"
70
+ redirect_to content_type_content_items_path
71
+ end
64
72
 
65
- add_breadcrumb content_type.name.pluralize, :content_type_content_items_path
66
- add_breadcrumb 'New'
73
+ m.failure :persist_content_item do |errors|
74
+ flash[:warning] = clean_error_messages(errors.full_messages)
75
+ render_create_content_item_error
76
+ end
67
77
 
68
- render :new
69
- else
70
- flash[:success] = "Hooray! #{content_type.name} Created!"
71
- redirect_to content_type_content_items_path
78
+ m.failure do |error|
79
+ flash[:warning] = ['Unknown System Error']
80
+ render_update_content_item_error
81
+ end
72
82
  end
73
83
  end
74
84
  end