Browse Source

ajout de la colonne can_edit dans la table join_team_users

Lou 3 years ago
parent
commit
7d7bbd0738

+ 3
- 0
app/models/joined_team_user.rb View File

@@ -1,4 +1,7 @@
1 1
 class JoinedTeamUser < ApplicationRecord
2 2
   belongs_to :user
3 3
   belongs_to :team
4
+
5
+  validates_associated :user, on: :create
6
+  validates_associated :team, on: :create
4 7
 end

+ 1
- 0
db/migrate/20210803152520_create_joined_team_users.rb View File

@@ -3,6 +3,7 @@ class CreateJoinedTeamUsers < ActiveRecord::Migration[6.1]
3 3
     create_table :joined_team_users do |t|
4 4
       t.references :user
5 5
       t.references :team
6
+      t.boolean :can_edit, default: false 
6 7
 
7 8
       t.timestamps
8 9
     end

+ 1
- 0
db/schema.rb View File

@@ -29,6 +29,7 @@ ActiveRecord::Schema.define(version: 2021_08_03_152520) do
29 29
   create_table "joined_team_users", force: :cascade do |t|
30 30
     t.bigint "user_id"
31 31
     t.bigint "team_id"
32
+    t.boolean "can_edit", default: false
32 33
     t.datetime "created_at", precision: 6, null: false
33 34
     t.datetime "updated_at", precision: 6, null: false
34 35
     t.index ["team_id"], name: "index_joined_team_users_on_team_id"

+ 3
- 1
db/seeds.rb View File

@@ -39,8 +39,10 @@ end
39 39
   
40 40
   joined_team_users = JoinedTeamUser.create!(
41 41
     user_id: user.id,
42
-    team_id: Team.all.sample.id
42
+    team_id: Team.all.sample.id,
43
+    can_edit: true
43 44
   )
45
+  puts "USER ##{joined_team_users.user_id} joined TEAM ##{joined_team_users.team_id}"
44 46
 end
45 47
 
46 48
 User.create! username: "admin", email: "admin@email.com", password: "azerty", is_admin: true

+ 1
- 3
test/models/joined_team_user_test.rb View File

@@ -1,7 +1,5 @@
1 1
 require "test_helper"
2 2
 
3 3
 class JoinedTeamUserTest < ActiveSupport::TestCase
4
-  # test "the truth" do
5
-  #   assert true
6
-  # end
4
+
7 5
 end

Loading…
Cancel
Save