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
 class JoinedTeamUser < ApplicationRecord
1
 class JoinedTeamUser < ApplicationRecord
2
   belongs_to :user
2
   belongs_to :user
3
   belongs_to :team
3
   belongs_to :team
4
+
5
+  validates_associated :user, on: :create
6
+  validates_associated :team, on: :create
4
 end
7
 end

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

3
     create_table :joined_team_users do |t|
3
     create_table :joined_team_users do |t|
4
       t.references :user
4
       t.references :user
5
       t.references :team
5
       t.references :team
6
+      t.boolean :can_edit, default: false 
6
 
7
 
7
       t.timestamps
8
       t.timestamps
8
     end
9
     end

+ 1
- 0
db/schema.rb View File

29
   create_table "joined_team_users", force: :cascade do |t|
29
   create_table "joined_team_users", force: :cascade do |t|
30
     t.bigint "user_id"
30
     t.bigint "user_id"
31
     t.bigint "team_id"
31
     t.bigint "team_id"
32
+    t.boolean "can_edit", default: false
32
     t.datetime "created_at", precision: 6, null: false
33
     t.datetime "created_at", precision: 6, null: false
33
     t.datetime "updated_at", precision: 6, null: false
34
     t.datetime "updated_at", precision: 6, null: false
34
     t.index ["team_id"], name: "index_joined_team_users_on_team_id"
35
     t.index ["team_id"], name: "index_joined_team_users_on_team_id"

+ 3
- 1
db/seeds.rb View File

39
   
39
   
40
   joined_team_users = JoinedTeamUser.create!(
40
   joined_team_users = JoinedTeamUser.create!(
41
     user_id: user.id,
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
 end
46
 end
45
 
47
 
46
 User.create! username: "admin", email: "admin@email.com", password: "azerty", is_admin: true
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
 require "test_helper"
1
 require "test_helper"
2
 
2
 
3
 class JoinedTeamUserTest < ActiveSupport::TestCase
3
 class JoinedTeamUserTest < ActiveSupport::TestCase
4
-  # test "the truth" do
5
-  #   assert true
6
-  # end
4
+
7
 end
5
 end

Loading…
Cancel
Save