Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

WIP: Add time_entry_activity_spec

Mir Bhatia6bc9b6a37b25
diff --git a/modules/costs/spec/models/time_entry_spec.rb b/modules/costs/spec/models/time_entry_spec.rb
index 19037c63878..cae3c56555a 100644
--- a/modules/costs/spec/models/time_entry_spec.rb
+++ b/modules/costs/spec/models/time_entry_spec.rb
@@ -108,7 +108,7 @@ describe TimeEntry do
end
end
- it 'alwayses prefer overridden_costs' do
+ it 'always prefers overridden_costs' do
allow(User).to receive(:current).and_return(user)
value = rand(500)
diff --git a/spec/features/activities/time_entry_activity_spec.rb b/spec/features/activities/time_entry_activity_spec.rb
index c0b3756910f..182824cfbdc 100644
--- a/spec/features/activities/time_entry_activity_spec.rb
+++ b/spec/features/activities/time_entry_activity_spec.rb
@@ -38,3 +38,58 @@
# # Activity is updated as specified
# end
+
+require 'spec_helper'
+
+describe 'TimeEntry activities' do
+ let(:user) do
+ create(:user,
+ member_in_project: project,
+ member_with_permissions: %w[log_time
+ view_time_entries
+ view_own_time_entries
+ edit_own_time_entries
+ view_work_packages
+ edit_work_packages
+ edit_time_entries])
+ end
+ let(:project) { create(:project_with_types, enabled_module_names: %w[costs activity work_package_tracking]) }
+ let(:work_package) { create(:work_package, project:, type: project.types.first) }
+ let(:hours) { 5.0 }
+ let(:time_entry) do
+ create(:time_entry,
+ project:,
+ work_package:,
+ spent_on: Date.today,
+ hours:,
+ user:,
+ comments: 'lorem ipsum')
+ end
+ # let(:wiki) { project.wiki }
+ # let(:editor) { Components::WysiwygEditor.new }
+
+ before do
+ login_as user
+ end
+
+ it 'tracks the time_entry\'s activities', js: true do
+ work_package.save!
+ time_entry.save!
+ visit project_activity_index_path(project)
+
+ check 'Spent time'
+ uncheck 'Work packages'
+
+ click_button 'Apply'
+ binding.pry
+
+ within("li.op-activity-list--item", match: :first) do
+ expect(page).to have_link("#{project.types.first} ##{work_package.id}: #{work_package.subject}") # follow link?
+ expect(page).to have_selector('li', text: "Spent time: #{time_entry.hours.to_i} hours")
+ expect(page).to have_link('Details')
+
+ click_link('Details')
+ expect(find_field('Work Package Value').value).to eq("#{work_package.id}")
+ end
+ end
+end