|
@@ -26,6 +26,9 @@ fn lead_cannot_create_channel() {
|
|
|
#[test]
|
|
|
fn curators_can_create_channel() {
|
|
|
with_default_mock_builder(|| {
|
|
|
+ // Run to block one to see emitted events
|
|
|
+ run_to_block(1);
|
|
|
+
|
|
|
// Curator group doesn't exist yet
|
|
|
assert_err!(
|
|
|
Content::create_channel(
|
|
@@ -71,6 +74,8 @@ fn curators_can_create_channel() {
|
|
|
Error::<Test>::CuratorAuthFailed
|
|
|
);
|
|
|
|
|
|
+ let channel_id = Content::next_channel_id();
|
|
|
+
|
|
|
// Curator in correct active group, with correct origin
|
|
|
assert_ok!(Content::create_channel(
|
|
|
Origin::signed(FIRST_CURATOR_ORIGIN),
|
|
@@ -81,11 +86,36 @@ fn curators_can_create_channel() {
|
|
|
reward_account: None,
|
|
|
}
|
|
|
));
|
|
|
+
|
|
|
+ assert_eq!(
|
|
|
+ System::events().last().unwrap().event,
|
|
|
+ MetaEvent::content(RawEvent::ChannelCreated(
|
|
|
+ ContentActor::Curator(FIRST_CURATOR_GROUP_ID, FIRST_CURATOR_ID),
|
|
|
+ channel_id,
|
|
|
+ ChannelRecord {
|
|
|
+ owner: ChannelOwner::CuratorGroup(FIRST_CURATOR_GROUP_ID),
|
|
|
+ videos: vec![],
|
|
|
+ playlists: vec![],
|
|
|
+ series: vec![],
|
|
|
+ is_censored: false,
|
|
|
+ reward_account: None,
|
|
|
+ },
|
|
|
+ ChannelCreationParameters {
|
|
|
+ assets: vec![],
|
|
|
+ meta: vec![],
|
|
|
+ reward_account: None,
|
|
|
+ }
|
|
|
+ ))
|
|
|
+ );
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
#[test]
|
|
|
fn members_can_manage_channels() {
|
|
|
with_default_mock_builder(|| {
|
|
|
+ // Run to block one to see emitted events
|
|
|
+ run_to_block(1);
|
|
|
+
|
|
|
// Not a member
|
|
|
assert_err!(
|
|
|
Content::create_channel(
|
|
@@ -113,7 +143,26 @@ fn members_can_manage_channels() {
|
|
|
}
|
|
|
));
|
|
|
|
|
|
- // TODO: assert emitted events...
|
|
|
+ assert_eq!(
|
|
|
+ System::events().last().unwrap().event,
|
|
|
+ MetaEvent::content(RawEvent::ChannelCreated(
|
|
|
+ ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ channel_id_1,
|
|
|
+ ChannelRecord {
|
|
|
+ owner: ChannelOwner::Member(FIRST_MEMBER_ID),
|
|
|
+ videos: vec![],
|
|
|
+ playlists: vec![],
|
|
|
+ series: vec![],
|
|
|
+ is_censored: false,
|
|
|
+ reward_account: None,
|
|
|
+ },
|
|
|
+ ChannelCreationParameters {
|
|
|
+ assets: vec![],
|
|
|
+ meta: vec![],
|
|
|
+ reward_account: None,
|
|
|
+ }
|
|
|
+ ))
|
|
|
+ );
|
|
|
|
|
|
let channel_id_2 = Content::next_channel_id();
|
|
|
|
|
@@ -128,7 +177,26 @@ fn members_can_manage_channels() {
|
|
|
}
|
|
|
));
|
|
|
|
|
|
- // TODO: assert emitted events...
|
|
|
+ assert_eq!(
|
|
|
+ System::events().last().unwrap().event,
|
|
|
+ MetaEvent::content(RawEvent::ChannelCreated(
|
|
|
+ ContentActor::Member(SECOND_MEMBER_ID),
|
|
|
+ channel_id_2,
|
|
|
+ ChannelRecord {
|
|
|
+ owner: ChannelOwner::Member(SECOND_MEMBER_ID),
|
|
|
+ videos: vec![],
|
|
|
+ playlists: vec![],
|
|
|
+ series: vec![],
|
|
|
+ is_censored: false,
|
|
|
+ reward_account: None,
|
|
|
+ },
|
|
|
+ ChannelCreationParameters {
|
|
|
+ assets: vec![],
|
|
|
+ meta: vec![],
|
|
|
+ reward_account: None,
|
|
|
+ }
|
|
|
+ ))
|
|
|
+ );
|
|
|
|
|
|
// Update channel
|
|
|
assert_ok!(Content::update_channel(
|
|
@@ -142,7 +210,26 @@ fn members_can_manage_channels() {
|
|
|
}
|
|
|
));
|
|
|
|
|
|
- // TODO: assert emitted events...
|
|
|
+ assert_eq!(
|
|
|
+ System::events().last().unwrap().event,
|
|
|
+ MetaEvent::content(RawEvent::ChannelUpdated(
|
|
|
+ ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ channel_id_1,
|
|
|
+ ChannelRecord {
|
|
|
+ owner: ChannelOwner::Member(FIRST_MEMBER_ID),
|
|
|
+ videos: vec![],
|
|
|
+ playlists: vec![],
|
|
|
+ series: vec![],
|
|
|
+ is_censored: false,
|
|
|
+ reward_account: None,
|
|
|
+ },
|
|
|
+ ChannelUpdateParameters {
|
|
|
+ assets: None,
|
|
|
+ new_meta: None,
|
|
|
+ reward_account: None,
|
|
|
+ }
|
|
|
+ ))
|
|
|
+ );
|
|
|
|
|
|
// Member cannot update a channel they do not own
|
|
|
assert_err!(
|
|
@@ -158,7 +245,68 @@ fn members_can_manage_channels() {
|
|
|
),
|
|
|
Error::<Test>::ActorNotAuthorized
|
|
|
);
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+#[test]
|
|
|
+fn curators_can_censor_channels() {
|
|
|
+ with_default_mock_builder(|| {
|
|
|
+ // Run to block one to see emitted events
|
|
|
+ run_to_block(1);
|
|
|
+
|
|
|
+ let channel_id = Content::next_channel_id();
|
|
|
+ assert_ok!(Content::create_channel(
|
|
|
+ Origin::signed(FIRST_MEMBER_ORIGIN),
|
|
|
+ ContentActor::Member(FIRST_MEMBER_ID),
|
|
|
+ ChannelCreationParameters {
|
|
|
+ assets: vec![],
|
|
|
+ meta: vec![],
|
|
|
+ reward_account: None,
|
|
|
+ }
|
|
|
+ ));
|
|
|
+
|
|
|
+ let group_id = curators::add_curator_to_new_group(FIRST_CURATOR_ID);
|
|
|
+
|
|
|
+ // Curator can censor channels
|
|
|
+ assert_ok!(Content::censor_channel(
|
|
|
+ Origin::signed(FIRST_CURATOR_ORIGIN),
|
|
|
+ ContentActor::Curator(group_id, FIRST_CURATOR_ID),
|
|
|
+ channel_id,
|
|
|
+ vec![]
|
|
|
+ ));
|
|
|
+
|
|
|
+ assert_eq!(
|
|
|
+ System::events().last().unwrap().event,
|
|
|
+ MetaEvent::content(RawEvent::ChannelCensored(
|
|
|
+ ContentActor::Curator(group_id, FIRST_CURATOR_ID),
|
|
|
+ channel_id,
|
|
|
+ vec![]
|
|
|
+ ))
|
|
|
+ );
|
|
|
+
|
|
|
+ let channel = Content::channel_by_id(channel_id);
|
|
|
+
|
|
|
+ assert!(channel.is_censored);
|
|
|
+
|
|
|
+ // Curator can un-censor channels
|
|
|
+ assert_ok!(Content::uncensor_channel(
|
|
|
+ Origin::signed(FIRST_CURATOR_ORIGIN),
|
|
|
+ ContentActor::Curator(group_id, FIRST_CURATOR_ID),
|
|
|
+ channel_id,
|
|
|
+ vec![]
|
|
|
+ ));
|
|
|
+
|
|
|
+ assert_eq!(
|
|
|
+ System::events().last().unwrap().event,
|
|
|
+ MetaEvent::content(RawEvent::ChannelUncensored(
|
|
|
+ ContentActor::Curator(group_id, FIRST_CURATOR_ID),
|
|
|
+ channel_id,
|
|
|
+ vec![]
|
|
|
+ ))
|
|
|
+ );
|
|
|
+
|
|
|
+ let channel = Content::channel_by_id(channel_id);
|
|
|
|
|
|
- // TODO: assert emitted events...
|
|
|
+ assert!(!channel.is_censored);
|
|
|
})
|
|
|
}
|