mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
FIX: PM should never be allowed to have a category
FIX: TL3 should not be allowed to muck with PM titles
This commit is contained in:
@ -39,7 +39,7 @@ describe Draft do
|
||||
it 'nukes new topic draft after a topic is created' do
|
||||
u = Fabricate(:user)
|
||||
Draft.set(u, Draft::NEW_TOPIC, 0, 'my draft')
|
||||
t = Fabricate(:topic, user: u)
|
||||
_t = Fabricate(:topic, user: u)
|
||||
s = DraftSequence.current(u, Draft::NEW_TOPIC)
|
||||
Draft.get(u, Draft::NEW_TOPIC, s).should be_nil
|
||||
end
|
||||
@ -47,7 +47,7 @@ describe Draft do
|
||||
it 'nukes new pm draft after a pm is created' do
|
||||
u = Fabricate(:user)
|
||||
Draft.set(u, Draft::NEW_PRIVATE_MESSAGE, 0, 'my draft')
|
||||
t = Fabricate(:topic, user: u, archetype: Archetype.private_message)
|
||||
t = Fabricate(:topic, user: u, archetype: Archetype.private_message, category_id: nil)
|
||||
s = DraftSequence.current(t.user, Draft::NEW_PRIVATE_MESSAGE)
|
||||
Draft.get(u, Draft::NEW_PRIVATE_MESSAGE, s).should be_nil
|
||||
end
|
||||
@ -55,7 +55,7 @@ describe Draft do
|
||||
it 'does not nuke new topic draft after a pm is created' do
|
||||
u = Fabricate(:user)
|
||||
Draft.set(u, Draft::NEW_TOPIC, 0, 'my draft')
|
||||
t = Fabricate(:topic, user: u, archetype: Archetype.private_message)
|
||||
t = Fabricate(:topic, user: u, archetype: Archetype.private_message, category_id: nil)
|
||||
s = DraftSequence.current(t.user, Draft::NEW_TOPIC)
|
||||
Draft.get(u, Draft::NEW_TOPIC, s).should == 'my draft'
|
||||
end
|
||||
|
@ -108,17 +108,18 @@ describe Invite do
|
||||
end
|
||||
|
||||
context 'an existing user' do
|
||||
let(:topic) { Fabricate(:topic, archetype: Archetype.private_message) }
|
||||
let(:topic) { Fabricate(:topic, category_id: nil, archetype: 'private_message') }
|
||||
let(:coding_horror) { Fabricate(:coding_horror) }
|
||||
let!(:invite) { topic.invite_by_email(topic.user, coding_horror.email) }
|
||||
|
||||
it "doesn't create an invite" do
|
||||
it "works" do
|
||||
# doesn't create an invite
|
||||
invite.should be_blank
|
||||
end
|
||||
|
||||
it "gives the user permission to access the topic" do
|
||||
# gives the user permission to access the topic
|
||||
topic.allowed_users.include?(coding_horror).should be_true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context '.redeem' do
|
||||
@ -254,7 +255,7 @@ describe Invite do
|
||||
let!(:user) { invite.redeem }
|
||||
|
||||
let(:coding_horror) { User.find_by(username: "CodingHorror") }
|
||||
let(:another_topic) { Fabricate(:topic, archetype: "private_message", user: coding_horror) }
|
||||
let(:another_topic) { Fabricate(:topic, category_id: nil, archetype: "private_message", user: coding_horror) }
|
||||
|
||||
it 'adds the user to the topic_users of the first topic' do
|
||||
topic.allowed_users.include?(user).should be_true
|
||||
|
@ -66,7 +66,7 @@ describe PostAlertObserver do
|
||||
let(:mention_post) { Fabricate(:post, user: user, raw: 'Hello @eviltrout')}
|
||||
let(:topic) do
|
||||
topic = mention_post.topic
|
||||
topic.update_column :archetype, Archetype.private_message
|
||||
topic.update_columns archetype: Archetype.private_message, category_id: nil
|
||||
topic
|
||||
end
|
||||
|
||||
|
@ -217,7 +217,7 @@ http://b.com/#{'a'*500}
|
||||
|
||||
describe 'internal link from pm' do
|
||||
it 'works' do
|
||||
pm = Fabricate(:topic, user: user, archetype: 'private_message')
|
||||
pm = Fabricate(:topic, user: user, category_id: nil, archetype: 'private_message')
|
||||
pm.posts.create(user: user, raw: "some content")
|
||||
|
||||
url = "http://#{test_uri.host}/t/topic-slug/#{topic.id}"
|
||||
|
@ -7,7 +7,8 @@ describe TopicParticipantsSummary do
|
||||
let(:topic) do
|
||||
Fabricate(:topic,
|
||||
user: topic_creator,
|
||||
archetype: Archetype::private_message
|
||||
archetype: Archetype::private_message,
|
||||
category_id: nil
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -801,16 +801,22 @@ describe Topic do
|
||||
context 'changing category' do
|
||||
let(:category) { Fabricate(:category) }
|
||||
|
||||
before do
|
||||
it "creates a new revision" do
|
||||
topic.change_category_to_id(category.id)
|
||||
post.revisions.size.should == 1
|
||||
end
|
||||
|
||||
it "creates a new revision" do
|
||||
post.revisions.size.should == 1
|
||||
it "does nothing for private messages" do
|
||||
topic.archetype = "private_message"
|
||||
topic.category_id = nil
|
||||
|
||||
topic.change_category_to_id(category.id)
|
||||
topic.category_id.should == nil
|
||||
end
|
||||
|
||||
context "removing a category" do
|
||||
before do
|
||||
topic.change_category_to_id(category.id)
|
||||
topic.change_category_to_id(nil)
|
||||
end
|
||||
|
||||
|
@ -18,7 +18,7 @@ describe UserAction do
|
||||
let(:private_post) { Fabricate(:post) }
|
||||
let(:private_topic) do
|
||||
topic = private_post.topic
|
||||
topic.update_column(:archetype, Archetype::private_message)
|
||||
topic.update_columns(category_id: nil, archetype: Archetype::private_message)
|
||||
topic
|
||||
end
|
||||
|
||||
@ -136,7 +136,7 @@ describe UserAction do
|
||||
context "liking a private message" do
|
||||
|
||||
before do
|
||||
post.topic.update_column(:archetype, Archetype::private_message)
|
||||
post.topic.update_columns(category_id: nil, archetype: Archetype::private_message)
|
||||
end
|
||||
|
||||
it "doesn't add the entry to the stream" do
|
||||
|
Reference in New Issue
Block a user