Browse Source

Added duration field to Task migration, timestamps fields are now sent with def show in Task controller

Lou 3 years ago
parent
commit
37e7828183

+ 1
- 1
app/controllers/api/v1/tasks_controller.rb View File

41
   private
41
   private
42
 
42
 
43
   def task_params
43
   def task_params
44
-    params.require(:task).permit(:name, :description, :activity_id)
44
+    params.require(:task).permit(:name, :description, :duration, :activity_id, :created_at, :updated_at)
45
   end
45
   end
46
 
46
 
47
   def set_task
47
   def set_task

+ 1
- 1
app/serializers/task_serializer.rb View File

1
 class TaskSerializer
1
 class TaskSerializer
2
   include JSONAPI::Serializer
2
   include JSONAPI::Serializer
3
-  attributes :name, :description, :user_id, :activity_id
3
+  attributes :name, :description, :duration, :user_id, :activity_id, :created_at, :updated_at
4
 
4
 
5
   cache_options store: Rails.cache, namespace: 'jsonapi-serializer', expires_in: 1.hour
5
   cache_options store: Rails.cache, namespace: 'jsonapi-serializer', expires_in: 1.hour
6
 end
6
 end

+ 1
- 0
db/migrate/20210510133939_create_tasks.rb View File

4
       t.string :name, null: false
4
       t.string :name, null: false
5
       t.index :name
5
       t.index :name
6
       t.text :description
6
       t.text :description
7
+      t.integer :duration
7
       t.references :activity, null: false
8
       t.references :activity, null: false
8
       t.references :user, null: false
9
       t.references :user, null: false
9
 
10
 

+ 1
- 0
db/schema.rb View File

35
   create_table "tasks", force: :cascade do |t|
35
   create_table "tasks", force: :cascade do |t|
36
     t.string "name", null: false
36
     t.string "name", null: false
37
     t.text "description"
37
     t.text "description"
38
+    t.integer "duration"
38
     t.integer "activity_id", null: false
39
     t.integer "activity_id", null: false
39
     t.integer "user_id", null: false
40
     t.integer "user_id", null: false
40
     t.datetime "created_at", precision: 6, null: false
41
     t.datetime "created_at", precision: 6, null: false

+ 1
- 0
db/seeds.rb View File

33
   task = Task.create(
33
   task = Task.create(
34
     name: Faker::Fantasy::Tolkien.character,
34
     name: Faker::Fantasy::Tolkien.character,
35
     description: Faker::Fantasy::Tolkien.poem,
35
     description: Faker::Fantasy::Tolkien.poem,
36
+    duration: rand(1..120),
36
     user_id: User.all.sample.id,
37
     user_id: User.all.sample.id,
37
     activity_id: Activity.all.sample.id
38
     activity_id: Activity.all.sample.id
38
   )
39
   )

BIN
erd.pdf View File


+ 1
- 0
test/fixtures/tasks.yml View File

3
 one:
3
 one:
4
   name: Do something
4
   name: Do something
5
   description: Description of a task
5
   description: Description of a task
6
+  duration: 60
6
   user: one
7
   user: one
7
   activity: one
8
   activity: one

+ 1
- 1
test/test_helper.rb View File

10
   fixtures :all
10
   fixtures :all
11
 
11
 
12
   # Add more helper methods to be used by all tests here...
12
   # Add more helper methods to be used by all tests here...
13
-end
13
+end

Loading…
Cancel
Save