Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
add activity for moving namespaces
Browse files Browse the repository at this point in the history
When a namespace is assigned a new team, an activity is created.

Resolves #877

Signed-off-by: Thomas Hipp <thipp@suse.com>
  • Loading branch information
Thomas Hipp committed May 30, 2016
1 parent 3b0365e commit bee1502
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/controllers/namespaces_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ def update
if @team.nil?
@namespace.errors[:team_id] << "'#{p[:team]}' unknown."
else
@namespace.create_activity :change_team,
owner: current_user,
parameters: { old: @namespace.team.id, new: @team.id }
@namespace.update_attributes(team: @team)
end
end
Expand Down
1 change: 1 addition & 0 deletions app/views/public_activity/namespace/_change_team.csv.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= CSV.generate_line(['namespace', activity.trackable.name, 'change team', '-', activity.owner.username, activity.created_at, "owned by team #{activity.trackable.team.name}"])
17 changes: 17 additions & 0 deletions app/views/public_activity/namespace/_change_team.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
li
.activitie-container
.activity-type.change-team
i.fa.fa-arrow-right
.user-image
= user_image_tag(activity.owner.email)
.description
h6
strong
= "#{activity.owner.username} moved the "
= link_to activity.trackable.name , activity.trackable
= " namespace to the "
= link_to activity.trackable.team.name, activity.trackable.team
= " team"
small
i.fa.fa-clock-o
= activity_time_tag activity.created_at
13 changes: 13 additions & 0 deletions spec/controllers/namespaces_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -334,5 +334,18 @@
expect(namespace_description_activity.parameters[:old]).to eq(old_description)
expect(namespace_description_activity.parameters[:new]).to eq("new description")
end

it "tracks change team" do
team2 = create(:team)
expect do
patch :update, id: namespace.id, namespace: { team: team2.name }, format: "js"
end.to change(PublicActivity::Activity, :count).by(1)
namespace_change_team_activity = PublicActivity::Activity.find_by(
key: "namespace.change_team")
expect(namespace_change_team_activity.owner).to eq(owner)
expect(namespace_change_team_activity.trackable).to eq(namespace)
expect(namespace_change_team_activity.parameters[:old]).to eq(team.id)
expect(namespace_change_team_activity.parameters[:new]).to eq(team2.id)
end
end
end

0 comments on commit bee1502

Please sign in to comment.