Skip to content

Commit

Permalink
Fix Channels Controller tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jules2689 committed Sep 16, 2021
1 parent 69c6d1e commit 02e6885
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/models/channel.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class Channel < ApplicationRecord
belongs_to :creator, class_name: "User", foreign_key: :user_id, optional: true

has_many :memberships
has_many :memberships, dependent: :destroy
has_many :members, through: :memberships, source: :user

has_many :active_memberships, -> { kept }, class_name: "Membership"
has_many :active_members, through: :active_memberships, source: :user

has_many :messages, as: :recipient
has_many :messages, as: :recipient, dependent: :destroy

validates :name, length: { maximum: 80 }, presence: true, uniqueness: true
validates :description, length: { maximum: 240 }
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/channels_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ChannelsControllerTest < ActionDispatch::IntegrationTest

test "should create channel" do
assert_difference('Channel.count') do
post channels_url, params: { channel: { description: @channel.description, name: @channel.name, user_id: @channel.user_id } }
post channels_url, params: { channel: { description: @channel.description, name: @channel.name + "_unique", user_id: @channel.user_id } }
end

assert_redirected_to channel_url(Channel.last)
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/channels.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
name: MyString
name: ChannelName1
description: MyText
creator: one

two:
name: MyString
name: ChannelName2
description: MyText
creator: two

0 comments on commit 02e6885

Please # to comment.