Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
115 lines (109 sloc) 3.13 KB
generate-story-status-model
From: Bryan Larsen <bryan@larsen.st>
## Have a configurable set of statuses
In order to support management of the statuses available, we'll create a StoryStatus model
$ hobo generate resource story_status name:string
---
app/controllers/story_statuses_controller.rb | 7 +++++
app/models/story_status.rb | 28 +++++++++++++++++++++
test/fixtures/story_statuses.yml | 11 ++++++++
test/functional/story_statuses_controller_test.rb | 8 ++++++
test/unit/story_status_test.rb | 8 ++++++
5 files changed, 62 insertions(+), 0 deletions(-)
create mode 100644 app/controllers/story_statuses_controller.rb
create mode 100644 app/models/story_status.rb
create mode 100644 test/fixtures/story_statuses.yml
create mode 100644 test/functional/story_statuses_controller_test.rb
create mode 100644 test/unit/story_status_test.rb
diff --git a/app/controllers/story_statuses_controller.rb b/app/controllers/story_statuses_controller.rb
new file mode 100644
index 0000000..53a3817
--- /dev/null
+++ b/app/controllers/story_statuses_controller.rb
@@ -0,0 +1,7 @@
+class StoryStatusesController < ApplicationController
+
+ hobo_model_controller
+
+ auto_actions :all
+
+end
diff --git a/app/models/story_status.rb b/app/models/story_status.rb
new file mode 100644
index 0000000..e568df0
--- /dev/null
+++ b/app/models/story_status.rb
@@ -0,0 +1,28 @@
+class StoryStatus < ActiveRecord::Base
+
+ hobo_model # Don't put anything above this
+
+ fields do
+ name :string
+ timestamps
+ end
+
+ # --- Permissions --- #
+
+ def create_permitted?
+ acting_user.administrator?
+ end
+
+ def update_permitted?
+ acting_user.administrator?
+ end
+
+ def destroy_permitted?
+ acting_user.administrator?
+ end
+
+ def view_permitted?(field)
+ true
+ end
+
+end
diff --git a/test/fixtures/story_statuses.yml b/test/fixtures/story_statuses.yml
new file mode 100644
index 0000000..2893341
--- /dev/null
+++ b/test/fixtures/story_statuses.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/functional/story_statuses_controller_test.rb b/test/functional/story_statuses_controller_test.rb
new file mode 100644
index 0000000..5be116b
--- /dev/null
+++ b/test/functional/story_statuses_controller_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class StoryStatusesControllerTest < ActionController::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
diff --git a/test/unit/story_status_test.rb b/test/unit/story_status_test.rb
new file mode 100644
index 0000000..be0b17c
--- /dev/null
+++ b/test/unit/story_status_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class StoryStatusTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
Something went wrong with that request. Please try again.