we_bridge_rails_engine_orgs 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/app/assets/javascripts/org_department_positions.js +2 -0
  4. data/app/assets/javascripts/org_departments.js +2 -0
  5. data/app/assets/stylesheets/org_department_positions.css +4 -0
  6. data/app/assets/stylesheets/org_departments.css +4 -0
  7. data/app/controllers/org_department_positions_controller.rb +58 -0
  8. data/app/controllers/org_departments_controller.rb +58 -0
  9. data/app/helpers/org_department_positions_helper.rb +2 -0
  10. data/app/helpers/org_departments_helper.rb +2 -0
  11. data/app/models/org.rb +11 -3
  12. data/app/models/org_branch.rb +15 -0
  13. data/app/models/org_department.rb +19 -0
  14. data/app/models/org_department_position.rb +26 -0
  15. data/app/models/org_department_position_member_mapping.rb +7 -0
  16. data/app/models/org_department_position_text.rb +10 -0
  17. data/app/models/org_department_text.rb +11 -0
  18. data/app/models/org_member.rb +5 -0
  19. data/app/views/org_department_positions/_form.html.builder +14 -0
  20. data/app/views/org_department_positions/edit.html.builder +7 -0
  21. data/app/views/org_department_positions/index.html.builder +25 -0
  22. data/app/views/org_department_positions/new.html.builder +5 -0
  23. data/app/views/org_department_positions/show.html.builder +8 -0
  24. data/app/views/org_departments/_form.html.builder +14 -0
  25. data/app/views/org_departments/edit.html.builder +7 -0
  26. data/app/views/org_departments/index.html.builder +25 -0
  27. data/app/views/org_departments/new.html.builder +5 -0
  28. data/app/views/org_departments/show.html.builder +8 -0
  29. data/config/routes.rb +3 -0
  30. data/db/migrate/20151204183447_create_org_departments.rb +18 -0
  31. data/db/migrate/20151204183612_create_org_department_positions.rb +26 -0
  32. data/lib/we_bridge_rails_engine_orgs/version.rb +1 -1
  33. data/spec/controllers/org_department_positions_controller_spec.rb +159 -0
  34. data/spec/controllers/org_departments_controller_spec.rb +159 -0
  35. data/spec/dummy/db/development.sqlite3 +0 -0
  36. data/spec/dummy/db/schema.rb +47 -1
  37. data/spec/dummy/db/test.sqlite3 +0 -0
  38. data/spec/dummy/log/development.log +1262 -0
  39. data/spec/dummy/log/test.log +3269 -0
  40. data/spec/factories/org_department_positions.rb +6 -0
  41. data/spec/factories/org_departments.rb +6 -0
  42. data/spec/helpers/org_department_positions_helper_spec.rb +15 -0
  43. data/spec/helpers/org_departments_helper_spec.rb +15 -0
  44. data/spec/models/org_branch_spec.rb +26 -1
  45. data/spec/models/org_department_position_spec.rb +5 -0
  46. data/spec/models/org_department_spec.rb +32 -0
  47. data/spec/models/org_member_spec.rb +18 -1
  48. data/spec/models/org_spec.rb +39 -1
  49. data/spec/routing/org_department_positions_routing_spec.rb +39 -0
  50. data/spec/routing/org_departments_routing_spec.rb +39 -0
  51. data/spec/views/org_department_positions/edit.html.builder_spec.rb +14 -0
  52. data/spec/views/org_department_positions/index.html.builder_spec.rb +14 -0
  53. data/spec/views/org_department_positions/new.html.builder_spec.rb +14 -0
  54. data/spec/views/org_department_positions/show.html.builder_spec.rb +11 -0
  55. data/spec/views/org_departments/edit.html.builder_spec.rb +14 -0
  56. data/spec/views/org_departments/index.html.builder_spec.rb +14 -0
  57. data/spec/views/org_departments/new.html.builder_spec.rb +14 -0
  58. data/spec/views/org_departments/show.html.builder_spec.rb +11 -0
  59. metadata +65 -4
  60. data/spec/dummy/tmp/pids/server.pid +0 -1
@@ -0,0 +1,5 @@
1
+ markup do |m|
2
+ m.h1 'New org_department'
3
+ m << render('form')
4
+ m << link_to('Back', org_departments_path)
5
+ end
@@ -0,0 +1,8 @@
1
+ markup do |m|
2
+ m.p id: 'notice'
3
+ m.dl do
4
+ end
5
+
6
+ m << link_to('Edit', edit_org_department_path(@org_department))
7
+ m << link_to('Back', org_departments_path)
8
+ end
data/config/routes.rb CHANGED
@@ -7,5 +7,8 @@ Rails.application.routes.draw do
7
7
  resources :org_branch_types, path: :branch_types, as: :branch_tyes
8
8
  resources :org_branches, path: :branches, as: :branches
9
9
  resources :org_activities, path: :activities, as: :activities
10
+ resources :org_departments, path: :departments, as: :departments do
11
+ resources :org_department_positions, path: :positions, as: :positions
12
+ end
10
13
  end
11
14
  end
@@ -0,0 +1,18 @@
1
+ class CreateOrgDepartments < ActiveRecord::Migration
2
+ def change
3
+ create_table :org_departments do |t|
4
+ t.integer :org_id, null: false
5
+ t.integer :manager_id, null: true
6
+ t.timestamps null: false
7
+ end
8
+
9
+ create_table :org_department_texts do |t|
10
+ t.integer :parent_id, null: false
11
+ t.integer :lang_id, null: false
12
+ t.string :name, null: false, default: ''
13
+ t.text :desc, null: false, default: ''
14
+ t.timestamps null: false
15
+ end
16
+ add_index :org_department_texts, [:lang_id,:parent_id], unique: true, name: :index_org_department_texts
17
+ end
18
+ end
@@ -0,0 +1,26 @@
1
+ class CreateOrgDepartmentPositions < ActiveRecord::Migration
2
+ def change
3
+ create_table :org_department_positions do |t|
4
+ t.integer :org_department_id, null: false
5
+ t.integer :position, null: false, default: 0
6
+ t.integer :limit, null: false, default: 0
7
+ t.timestamps null: false
8
+ end
9
+
10
+ create_table :org_department_position_texts do |t|
11
+ t.integer :parent_id, null: false
12
+ t.integer :lang_id, null: false
13
+ t.string :name, null: false, default: ''
14
+ t.text :desc, null: false, default: ''
15
+ t.timestamps null: false
16
+ end
17
+ add_index :org_department_position_texts, [:lang_id,:parent_id], unique: true, name: :index_org_department_position_texts
18
+
19
+ create_table :org_department_position_member_mappings do |t|
20
+ t.integer :org_department_position_id, null: false
21
+ t.integer :org_member_id, null: false
22
+ t.timestamps null: false
23
+ end
24
+ add_index :org_department_position_member_mappings, [:org_department_position_id,:org_member_id], unique: true, name: :index_org_department_position_member_mappings
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module WeBridgeRailsEngineOrgs
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -0,0 +1,159 @@
1
+ require 'rails_helper'
2
+
3
+ # This spec was generated by rspec-rails when you ran the scaffold generator.
4
+ # It demonstrates how one might use RSpec to specify the controller code that
5
+ # was generated by Rails when you ran the scaffold generator.
6
+ #
7
+ # It assumes that the implementation code is generated by the rails scaffold
8
+ # generator. If you are using any extension libraries to generate different
9
+ # controller code, this generated spec may or may not pass.
10
+ #
11
+ # It only uses APIs available in rails and/or rspec-rails. There are a number
12
+ # of tools you can use to make these specs even more expressive, but we're
13
+ # sticking to rails and rspec-rails APIs to keep things simple and stable.
14
+ #
15
+ # Compared to earlier versions of this generator, there is very limited use of
16
+ # stubs and message expectations in this spec. Stubs are only used when there
17
+ # is no simpler way to get a handle on the object needed for the example.
18
+ # Message expectations are only used when there is no simpler way to specify
19
+ # that an instance is receiving a specific message.
20
+
21
+ RSpec.describe OrgDepartmentPositionsController, type: :controller do
22
+
23
+ # This should return the minimal set of attributes required to create a valid
24
+ # OrgDepartmentPosition. As you add validations to OrgDepartmentPosition, be sure to
25
+ # adjust the attributes here as well.
26
+ let(:valid_attributes) {
27
+ skip("Add a hash of attributes valid for your model")
28
+ }
29
+
30
+ let(:invalid_attributes) {
31
+ skip("Add a hash of attributes invalid for your model")
32
+ }
33
+
34
+ # This should return the minimal set of values that should be in the session
35
+ # in order to pass any filters (e.g. authentication) defined in
36
+ # OrgDepartmentPositionsController. Be sure to keep this updated too.
37
+ let(:valid_session) { {} }
38
+
39
+ describe "GET #index" do
40
+ it "assigns all org_department_positions as @org_department_positions" do
41
+ org_department_position = OrgDepartmentPosition.create! valid_attributes
42
+ get :index, {}, valid_session
43
+ expect(assigns(:org_department_positions)).to eq([org_department_position])
44
+ end
45
+ end
46
+
47
+ describe "GET #show" do
48
+ it "assigns the requested org_department_position as @org_department_position" do
49
+ org_department_position = OrgDepartmentPosition.create! valid_attributes
50
+ get :show, {:id => org_department_position.to_param}, valid_session
51
+ expect(assigns(:org_department_position)).to eq(org_department_position)
52
+ end
53
+ end
54
+
55
+ describe "GET #new" do
56
+ it "assigns a new org_department_position as @org_department_position" do
57
+ get :new, {}, valid_session
58
+ expect(assigns(:org_department_position)).to be_a_new(OrgDepartmentPosition)
59
+ end
60
+ end
61
+
62
+ describe "GET #edit" do
63
+ it "assigns the requested org_department_position as @org_department_position" do
64
+ org_department_position = OrgDepartmentPosition.create! valid_attributes
65
+ get :edit, {:id => org_department_position.to_param}, valid_session
66
+ expect(assigns(:org_department_position)).to eq(org_department_position)
67
+ end
68
+ end
69
+
70
+ describe "POST #create" do
71
+ context "with valid params" do
72
+ it "creates a new OrgDepartmentPosition" do
73
+ expect {
74
+ post :create, {:org_department_position => valid_attributes}, valid_session
75
+ }.to change(OrgDepartmentPosition, :count).by(1)
76
+ end
77
+
78
+ it "assigns a newly created org_department_position as @org_department_position" do
79
+ post :create, {:org_department_position => valid_attributes}, valid_session
80
+ expect(assigns(:org_department_position)).to be_a(OrgDepartmentPosition)
81
+ expect(assigns(:org_department_position)).to be_persisted
82
+ end
83
+
84
+ it "redirects to the created org_department_position" do
85
+ post :create, {:org_department_position => valid_attributes}, valid_session
86
+ expect(response).to redirect_to(OrgDepartmentPosition.last)
87
+ end
88
+ end
89
+
90
+ context "with invalid params" do
91
+ it "assigns a newly created but unsaved org_department_position as @org_department_position" do
92
+ post :create, {:org_department_position => invalid_attributes}, valid_session
93
+ expect(assigns(:org_department_position)).to be_a_new(OrgDepartmentPosition)
94
+ end
95
+
96
+ it "re-renders the 'new' template" do
97
+ post :create, {:org_department_position => invalid_attributes}, valid_session
98
+ expect(response).to render_template("new")
99
+ end
100
+ end
101
+ end
102
+
103
+ describe "PUT #update" do
104
+ context "with valid params" do
105
+ let(:new_attributes) {
106
+ skip("Add a hash of attributes valid for your model")
107
+ }
108
+
109
+ it "updates the requested org_department_position" do
110
+ org_department_position = OrgDepartmentPosition.create! valid_attributes
111
+ put :update, {:id => org_department_position.to_param, :org_department_position => new_attributes}, valid_session
112
+ org_department_position.reload
113
+ skip("Add assertions for updated state")
114
+ end
115
+
116
+ it "assigns the requested org_department_position as @org_department_position" do
117
+ org_department_position = OrgDepartmentPosition.create! valid_attributes
118
+ put :update, {:id => org_department_position.to_param, :org_department_position => valid_attributes}, valid_session
119
+ expect(assigns(:org_department_position)).to eq(org_department_position)
120
+ end
121
+
122
+ it "redirects to the org_department_position" do
123
+ org_department_position = OrgDepartmentPosition.create! valid_attributes
124
+ put :update, {:id => org_department_position.to_param, :org_department_position => valid_attributes}, valid_session
125
+ expect(response).to redirect_to(org_department_position)
126
+ end
127
+ end
128
+
129
+ context "with invalid params" do
130
+ it "assigns the org_department_position as @org_department_position" do
131
+ org_department_position = OrgDepartmentPosition.create! valid_attributes
132
+ put :update, {:id => org_department_position.to_param, :org_department_position => invalid_attributes}, valid_session
133
+ expect(assigns(:org_department_position)).to eq(org_department_position)
134
+ end
135
+
136
+ it "re-renders the 'edit' template" do
137
+ org_department_position = OrgDepartmentPosition.create! valid_attributes
138
+ put :update, {:id => org_department_position.to_param, :org_department_position => invalid_attributes}, valid_session
139
+ expect(response).to render_template("edit")
140
+ end
141
+ end
142
+ end
143
+
144
+ describe "DELETE #destroy" do
145
+ it "destroys the requested org_department_position" do
146
+ org_department_position = OrgDepartmentPosition.create! valid_attributes
147
+ expect {
148
+ delete :destroy, {:id => org_department_position.to_param}, valid_session
149
+ }.to change(OrgDepartmentPosition, :count).by(-1)
150
+ end
151
+
152
+ it "redirects to the org_department_positions list" do
153
+ org_department_position = OrgDepartmentPosition.create! valid_attributes
154
+ delete :destroy, {:id => org_department_position.to_param}, valid_session
155
+ expect(response).to redirect_to(org_department_positions_url)
156
+ end
157
+ end
158
+
159
+ end
@@ -0,0 +1,159 @@
1
+ require 'rails_helper'
2
+
3
+ # This spec was generated by rspec-rails when you ran the scaffold generator.
4
+ # It demonstrates how one might use RSpec to specify the controller code that
5
+ # was generated by Rails when you ran the scaffold generator.
6
+ #
7
+ # It assumes that the implementation code is generated by the rails scaffold
8
+ # generator. If you are using any extension libraries to generate different
9
+ # controller code, this generated spec may or may not pass.
10
+ #
11
+ # It only uses APIs available in rails and/or rspec-rails. There are a number
12
+ # of tools you can use to make these specs even more expressive, but we're
13
+ # sticking to rails and rspec-rails APIs to keep things simple and stable.
14
+ #
15
+ # Compared to earlier versions of this generator, there is very limited use of
16
+ # stubs and message expectations in this spec. Stubs are only used when there
17
+ # is no simpler way to get a handle on the object needed for the example.
18
+ # Message expectations are only used when there is no simpler way to specify
19
+ # that an instance is receiving a specific message.
20
+
21
+ RSpec.describe OrgDepartmentsController, type: :controller do
22
+
23
+ # This should return the minimal set of attributes required to create a valid
24
+ # OrgDepartment. As you add validations to OrgDepartment, be sure to
25
+ # adjust the attributes here as well.
26
+ let(:valid_attributes) {
27
+ skip("Add a hash of attributes valid for your model")
28
+ }
29
+
30
+ let(:invalid_attributes) {
31
+ skip("Add a hash of attributes invalid for your model")
32
+ }
33
+
34
+ # This should return the minimal set of values that should be in the session
35
+ # in order to pass any filters (e.g. authentication) defined in
36
+ # OrgDepartmentsController. Be sure to keep this updated too.
37
+ let(:valid_session) { {} }
38
+
39
+ describe "GET #index" do
40
+ it "assigns all org_departments as @org_departments" do
41
+ org_department = OrgDepartment.create! valid_attributes
42
+ get :index, {}, valid_session
43
+ expect(assigns(:org_departments)).to eq([org_department])
44
+ end
45
+ end
46
+
47
+ describe "GET #show" do
48
+ it "assigns the requested org_department as @org_department" do
49
+ org_department = OrgDepartment.create! valid_attributes
50
+ get :show, {:id => org_department.to_param}, valid_session
51
+ expect(assigns(:org_department)).to eq(org_department)
52
+ end
53
+ end
54
+
55
+ describe "GET #new" do
56
+ it "assigns a new org_department as @org_department" do
57
+ get :new, {}, valid_session
58
+ expect(assigns(:org_department)).to be_a_new(OrgDepartment)
59
+ end
60
+ end
61
+
62
+ describe "GET #edit" do
63
+ it "assigns the requested org_department as @org_department" do
64
+ org_department = OrgDepartment.create! valid_attributes
65
+ get :edit, {:id => org_department.to_param}, valid_session
66
+ expect(assigns(:org_department)).to eq(org_department)
67
+ end
68
+ end
69
+
70
+ describe "POST #create" do
71
+ context "with valid params" do
72
+ it "creates a new OrgDepartment" do
73
+ expect {
74
+ post :create, {:org_department => valid_attributes}, valid_session
75
+ }.to change(OrgDepartment, :count).by(1)
76
+ end
77
+
78
+ it "assigns a newly created org_department as @org_department" do
79
+ post :create, {:org_department => valid_attributes}, valid_session
80
+ expect(assigns(:org_department)).to be_a(OrgDepartment)
81
+ expect(assigns(:org_department)).to be_persisted
82
+ end
83
+
84
+ it "redirects to the created org_department" do
85
+ post :create, {:org_department => valid_attributes}, valid_session
86
+ expect(response).to redirect_to(OrgDepartment.last)
87
+ end
88
+ end
89
+
90
+ context "with invalid params" do
91
+ it "assigns a newly created but unsaved org_department as @org_department" do
92
+ post :create, {:org_department => invalid_attributes}, valid_session
93
+ expect(assigns(:org_department)).to be_a_new(OrgDepartment)
94
+ end
95
+
96
+ it "re-renders the 'new' template" do
97
+ post :create, {:org_department => invalid_attributes}, valid_session
98
+ expect(response).to render_template("new")
99
+ end
100
+ end
101
+ end
102
+
103
+ describe "PUT #update" do
104
+ context "with valid params" do
105
+ let(:new_attributes) {
106
+ skip("Add a hash of attributes valid for your model")
107
+ }
108
+
109
+ it "updates the requested org_department" do
110
+ org_department = OrgDepartment.create! valid_attributes
111
+ put :update, {:id => org_department.to_param, :org_department => new_attributes}, valid_session
112
+ org_department.reload
113
+ skip("Add assertions for updated state")
114
+ end
115
+
116
+ it "assigns the requested org_department as @org_department" do
117
+ org_department = OrgDepartment.create! valid_attributes
118
+ put :update, {:id => org_department.to_param, :org_department => valid_attributes}, valid_session
119
+ expect(assigns(:org_department)).to eq(org_department)
120
+ end
121
+
122
+ it "redirects to the org_department" do
123
+ org_department = OrgDepartment.create! valid_attributes
124
+ put :update, {:id => org_department.to_param, :org_department => valid_attributes}, valid_session
125
+ expect(response).to redirect_to(org_department)
126
+ end
127
+ end
128
+
129
+ context "with invalid params" do
130
+ it "assigns the org_department as @org_department" do
131
+ org_department = OrgDepartment.create! valid_attributes
132
+ put :update, {:id => org_department.to_param, :org_department => invalid_attributes}, valid_session
133
+ expect(assigns(:org_department)).to eq(org_department)
134
+ end
135
+
136
+ it "re-renders the 'edit' template" do
137
+ org_department = OrgDepartment.create! valid_attributes
138
+ put :update, {:id => org_department.to_param, :org_department => invalid_attributes}, valid_session
139
+ expect(response).to render_template("edit")
140
+ end
141
+ end
142
+ end
143
+
144
+ describe "DELETE #destroy" do
145
+ it "destroys the requested org_department" do
146
+ org_department = OrgDepartment.create! valid_attributes
147
+ expect {
148
+ delete :destroy, {:id => org_department.to_param}, valid_session
149
+ }.to change(OrgDepartment, :count).by(-1)
150
+ end
151
+
152
+ it "redirects to the org_departments list" do
153
+ org_department = OrgDepartment.create! valid_attributes
154
+ delete :destroy, {:id => org_department.to_param}, valid_session
155
+ expect(response).to redirect_to(org_departments_url)
156
+ end
157
+ end
158
+
159
+ end
Binary file
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20151204024709) do
14
+ ActiveRecord::Schema.define(version: 20151204183612) do
15
15
 
16
16
  create_table "lang_texts", force: :cascade do |t|
17
17
  t.integer "parent_id", null: false
@@ -97,6 +97,52 @@ ActiveRecord::Schema.define(version: 20151204024709) do
97
97
  t.integer "position", default: 0, null: false
98
98
  end
99
99
 
100
+ create_table "org_department_position_member_mappings", force: :cascade do |t|
101
+ t.integer "org_department_position_id", null: false
102
+ t.integer "org_member_id", null: false
103
+ t.datetime "created_at", null: false
104
+ t.datetime "updated_at", null: false
105
+ end
106
+
107
+ add_index "org_department_position_member_mappings", ["org_department_position_id", "org_member_id"], name: "index_org_department_position_member_mappings", unique: true
108
+
109
+ create_table "org_department_position_texts", force: :cascade do |t|
110
+ t.integer "parent_id", null: false
111
+ t.integer "lang_id", null: false
112
+ t.string "name", default: "", null: false
113
+ t.text "desc", default: "", null: false
114
+ t.datetime "created_at", null: false
115
+ t.datetime "updated_at", null: false
116
+ end
117
+
118
+ add_index "org_department_position_texts", ["lang_id", "parent_id"], name: "index_org_department_position_texts", unique: true
119
+
120
+ create_table "org_department_positions", force: :cascade do |t|
121
+ t.integer "org_department_id", null: false
122
+ t.integer "position", default: 0, null: false
123
+ t.integer "limit", default: 0, null: false
124
+ t.datetime "created_at", null: false
125
+ t.datetime "updated_at", null: false
126
+ end
127
+
128
+ create_table "org_department_texts", force: :cascade do |t|
129
+ t.integer "parent_id", null: false
130
+ t.integer "lang_id", null: false
131
+ t.string "name", default: "", null: false
132
+ t.text "desc", default: "", null: false
133
+ t.datetime "created_at", null: false
134
+ t.datetime "updated_at", null: false
135
+ end
136
+
137
+ add_index "org_department_texts", ["lang_id", "parent_id"], name: "index_org_department_texts", unique: true
138
+
139
+ create_table "org_departments", force: :cascade do |t|
140
+ t.integer "org_id", null: false
141
+ t.integer "manager_id"
142
+ t.datetime "created_at", null: false
143
+ t.datetime "updated_at", null: false
144
+ end
145
+
100
146
  create_table "org_director_type_texts", force: :cascade do |t|
101
147
  t.integer "parent_id", null: false
102
148
  t.integer "lang_id", null: false