-
Notifications
You must be signed in to change notification settings - Fork 2
/
34-generate-story-status-model.patch
137 lines (130 loc) · 3.89 KB
/
34-generate-story-status-model.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
generate-story-status-model
From: Bryan Larsen <[email protected]>
## Have a configurable set of statuses
In order to support management of the statuses available, we'll create a StoryStatus model
$ ./script/generate hobo_model_resource story_status name:string
---
app/controllers/story_statuses_controller.rb | 7 +++++
app/helpers/story_statuses_helper.rb | 2 +
app/models/story_status.rb | 29 +++++++++++++++++++++
app/viewhints/story_status_hints.rb | 7 +++++
test/fixtures/story_statuses.yml | 6 ++++
test/functional/story_statuses_controller_test.rb | 8 ++++++
test/unit/story_status_test.rb | 8 ++++++
7 files changed, 67 insertions(+), 0 deletions(-)
create mode 100644 app/controllers/story_statuses_controller.rb
create mode 100644 app/helpers/story_statuses_helper.rb
create mode 100644 app/models/story_status.rb
create mode 100644 app/viewhints/story_status_hints.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/helpers/story_statuses_helper.rb b/app/helpers/story_statuses_helper.rb
new file mode 100644
index 0000000..0c9d639
--- /dev/null
+++ b/app/helpers/story_statuses_helper.rb
@@ -0,0 +1,2 @@
+module StoryStatusesHelper
+end
diff --git a/app/models/story_status.rb b/app/models/story_status.rb
new file mode 100644
index 0000000..2d01ab7
--- /dev/null
+++ b/app/models/story_status.rb
@@ -0,0 +1,29 @@
+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/app/viewhints/story_status_hints.rb b/app/viewhints/story_status_hints.rb
new file mode 100644
index 0000000..e5b821c
--- /dev/null
+++ b/app/viewhints/story_status_hints.rb
@@ -0,0 +1,7 @@
+class StoryStatusHints < Hobo::ViewHints
+
+ # model_name "My Model"
+ # field_names :field1 => "First Field", :field2 => "Second Field"
+ # field_help :field1 => "Enter what you want in this field"
+ # children :primary_collection1, :aside_collection1, :aside_collection2
+end
diff --git a/test/fixtures/story_statuses.yml b/test/fixtures/story_statuses.yml
new file mode 100644
index 0000000..5f81936
--- /dev/null
+++ b/test/fixtures/story_statuses.yml
@@ -0,0 +1,6 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+one:
+ id: 1
+
+two:
+ id: 2
diff --git a/test/functional/story_statuses_controller_test.rb b/test/functional/story_statuses_controller_test.rb
new file mode 100644
index 0000000..b7c2937
--- /dev/null
+++ b/test/functional/story_statuses_controller_test.rb
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class StoryStatusesControllerTest < ActionController::TestCase
+ # Replace this with your real tests.
+ def test_truth
+ 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..52cd5ed
--- /dev/null
+++ b/test/unit/story_status_test.rb
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class StoryStatusTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end