Skip to content

Commit

Permalink
feat: rename Researcher Classes -> Researcher Projects, add spec [PT-…
Browse files Browse the repository at this point in the history
  • Loading branch information
pjanik committed Mar 20, 2024
1 parent 7e450b6 commit fd1ce82
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
16 changes: 8 additions & 8 deletions rails/app/helpers/navigation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def show_admin_links
current_visitor.is_project_researcher?
end

def show_researcher_classes_links
def show_researcher_projects_links
current_visitor.is_project_researcher?
end

Expand Down Expand Up @@ -245,14 +245,14 @@ def project_link(project_link_spec)
}
end

def researcher_class_links
def researcher_project_links
if current_visitor.researcher_for_projects.empty?
return []
end

links = [{
id: '/researcher_classes',
label: nav_label('researcher_classes'),
id: '/researcher_projects',
label: nav_label('researcher_projects'),
type: NavigationService::SECTION_TYPE,
sort: 4
}]
Expand All @@ -261,9 +261,9 @@ def researcher_class_links

projects.each do |project|
links << {
id: "/researcher_classes/#{project.id}",
id: "/researcher_projects/#{project.id}",
label: project.name,
url: url_for(project)
url: url_for(project),
}
end

Expand Down Expand Up @@ -321,8 +321,8 @@ def navigation_service(params={})
service.add_item switch_user_link
end

if show_researcher_classes_links
researcher_class_links.each {|clazz_link| service.add_item clazz_link}
if show_researcher_projects_links
researcher_project_links.each {|clazz_link| service.add_item clazz_link}
end

clazz_links.each {|clazz_link| service.add_item clazz_link}
Expand Down
2 changes: 1 addition & 1 deletion rails/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ en:
full_status: Full Status
links: Links
switch_back: Switch back
researcher_classes: Researcher Classes
researcher_projects: Researcher Projects

'en-HAS':
activerecord:
Expand Down
18 changes: 18 additions & 0 deletions rails/spec/helpers/navigation_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
let(:fake_clazzes) { FactoryBot.create_list(:portal_clazz, 3)}
let(:fake_inactive_clazz) { FactoryBot.create(:portal_clazz, is_archived: true)}
let(:fake_student) { FactoryBot.create(:full_portal_student, clazzes: fake_clazzes) }
let(:fake_researcher) {
researcher = FactoryBot.generate(:researcher_user)
researcher.researcher_for_projects << FactoryBot.create(:project)
researcher
}
let(:fake_teacher) {
teacher = FactoryBot.create(:portal_teacher, clazzes: fake_clazzes)
teacher.teacher_clazzes.create(clazz: fake_inactive_clazz)
Expand Down Expand Up @@ -120,6 +125,19 @@
it "should not include favorites links" do
expect(subject).not_to match %r{"label": "Favorites"}
end

it "should not include researcher project links" do
expect(subject).not_to match %r{"label": "Researcher Projects"}
end
end

describe "researcher links" do
let(:fake_visitor) { fake_researcher }
subject { JSON.pretty_generate(helper.navigation_service(params).to_hash) }

it "should include researcher project links" do
expect(subject).to match %r{"label": "Researcher Projects"}
end
end

describe "selections" do
Expand Down

0 comments on commit fd1ce82

Please sign in to comment.